Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ios 5-EXC\u错误\u访问错误_Ios_Arrays_Memory Management - Fatal编程技术网

ios 5-EXC\u错误\u访问错误

ios 5-EXC\u错误\u访问错误,ios,arrays,memory-management,Ios,Arrays,Memory Management,请参阅下面的代码。为什么访问[self.objects count]会抛出这个错误,而在它证明self.objects存在之前的那一行呢 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. NSLog(@"HERE: %@", self.objects); //t

请参阅下面的代码。为什么访问[self.objects count]会抛出这个错误,而在它证明self.objects存在之前的那一行呢

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    NSLog(@"HERE: %@", self.objects); //this logs the array - no error
    NSLog(@"num rows: %@", [self.objects count]); //this line throws the error
    return [self.objects count];
}
在.h文件中,我有以下内容:

@interface YouTubeViewController_iPad : UITableViewController
{
    NSArray *_objects;
}

@property (nonatomic, retain) NSArray *objects;
在.m文件中:

@synthesize objects = _objects;

您需要正确格式化日志字符串:

NSLog(@"num rows: %@", [self.objects count]); //this line throws the error
[self.objects count]返回一个NSInteger,它是一个整数。理解整数不是对象是很重要的

请尝试以下方法:

NSLog(@"num rows: %i", [self.objects count]); //Notice the string formatter

您需要正确格式化日志字符串:

NSLog(@"num rows: %@", [self.objects count]); //this line throws the error
[self.objects count]返回一个NSInteger,它是一个整数。理解整数不是对象是很重要的

请尝试以下方法:

NSLog(@"num rows: %i", [self.objects count]); //Notice the string formatter
错误位于:

NSLog(@"num rows: %@", [self.objects count]); //this line throws the error
更新为:

NSLog(@"num rows: %d", [self.objects count]); //this line throws the error
错误位于:

NSLog(@"num rows: %@", [self.objects count]); //this line throws the error
更新为:

NSLog(@"num rows: %d", [self.objects count]); //this line throws the error