单击我的应用程序中的按钮时出现此错误:
2012-06-28 21:43:36.860 AppName[2403:707] *** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint'
*** First throw call stack:
(0x3568788f 0x37a2e259 0x35687789 0x356877ab 0x333a254d 0x333a26bb 0x333a2423 0x33333001 0x332a13c7 0x3317ec59 0x330f4c17 0x330ff267 0x330ff1d5 0x3319e59b 0x3319d367 0x331f86a7 0x8fb11 0x355e13fd 0x330d6e07 0x3319c5e7 0x355e13fd 0x330d6e07 0x330d6dc3 0x330d6da1 0x330d6b11 0x330d7449 0x330d592b 0x330d5319 0x330bb695 0x330baf3b 0x3727a22b 0x3565b523 0x3565b4c5 0x3565a313 0x355dd4a5 0x355dd36d 0x37279439 0x330e9cd5 0x8f6cb 0x8f628)
terminate called throwing an exception
Run Code Online (Sandbox Code Playgroud)
错误在这行代码上抱怨:
-(IBAction) goToAbout {
About *screen = [[ …Run Code Online (Sandbox Code Playgroud) 我收到错误控件可能会在此代码上达到非void函数的结尾:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (changeData.selectedSegmentIndex == 0) {
return self.tweets.count;
} else if (changeData.selectedSegmentIndex == 1) {
return self.tweets1.count;
} else if (changeData.selectedSegmentIndex == 2) {
return self.tweets2.count;
}
}
Run Code Online (Sandbox Code Playgroud)
为什么?
我正在尝试将JSON文件解析为我的iOS应用程序表视图.当我启动应用程序时,我看到它解析数据,但是当我开始滚动应用程序时,立即崩溃并给我这个错误:Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0x38094a60'
我的代码:
#import "FirstViewController.h"
#import "YoutubePost.h"
@interface FirstViewController ()
{
NSInteger refreshIndex;
NSArray *title;
NSArray *about;
NSArray *views;
NSArray *rating;
NSArray *votes;
NSArray *content;
}
@end
@implementation FirstViewController
@synthesize tweets;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"Videos", @"Videos");
self.tabBarItem.image = [UIImage imageNamed:@"newtab1"];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any …Run Code Online (Sandbox Code Playgroud) 我有一个JSON请求,返回不同的参数,例如名称.我想为name参数缓存一个变量,稍后我可以在app中查看.
例如:来自JSON request = david的名称.该变量称为firstname.firstname应该等于"david".应该存储名字,以便我可以在我的应用程序的所有部分中查看它.
我看到另一个类似的问题是一个解决方案是:
NSString *valueToSave = @"someValue";
[[NSUserDefaults standardUserDefaults]
setObject:valueToSave forKey:@"preferenceName"];
Run Code Online (Sandbox Code Playgroud)
并在以后取回它:
NSString *savedValue = [[NSUserDefaults standardUserDefaults]
stringForKey:@"preferenceName"];
Run Code Online (Sandbox Code Playgroud)
当我解析像这样的JSON文件时,如何使用此方法?:
@implementation Videos
@synthesize tableView = _tableView, activityIndicatorView = _activityIndicatorView, movies = _movies;
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Title";
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Menu"
style:UIBarButtonItemStylePlain
target:(DEMONavigationController *)self.navigationController
action:@selector(showMenu)];
NSString *valueToSave = @"TitleString";
[[NSUserDefaults standardUserDefaults]
setObject:valueToSave forKey:@"title"];
self.tableView.separatorColor = [UIColor clearColor];
// Setting Up Activity Indicator View
self.activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
self.activityIndicatorView.hidesWhenStopped = YES;
self.activityIndicatorView.center = self.view.center; …Run Code Online (Sandbox Code Playgroud) 我想显示一个像Pinterest一样的文字网格.我的网站是一个新闻提要网站,用户可以上传文本.
用于显示和从数据库获取文本的代码是:
<?php
//connect
mysql_connect("host","username","password") or die(mysql_error());
mysql_select_db("database_name") or die(mysql_error());
//query the database
$getnews = mysql_query("SELECT * FROM news ORDER BY id DESC") or die(mysql_query());
while ($row = mysql_fetch_assoc($getnews))
{
//get data
$id = $row['id'];
$title = $row['title'];
$body = $row['body'];
$date = $row['date'];
echo "
<b>$title posted on $date</b><br>
";
echo nl2br($body);
echo "<hr>
";
}
?>
Run Code Online (Sandbox Code Playgroud)
发布文本的代码如下:
<?php
//insert category to database
if(isset($_POST['qty'])) {
// Fetch and clean the <select> value.
// The (int) makes sure the value …Run Code Online (Sandbox Code Playgroud)