1
請參閱下面的代碼。爲什麼訪問[self.objects計數]拋出這個錯誤,當直接在它之前的行證明self.objects存在?ios 5 - EXC_BAD_ACCESS錯誤
- (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;