ios 5-EXC\u错误\u访问错误
请参阅下面的代码。为什么访问[self.objects count]会抛出这个错误,而在它证明self.objects存在之前的那一行呢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
- (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