當我越來越想看到的NSMutableArray的內容時,這個錯誤:EXC_BAD_ACCESS調試
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000021
0x94d5a688 in objc_msgSend()
ViewController.h:
@interface PeopleViewController : UITableViewController {
NSMutableArray *people;
}
@property (nonatomic, retain) NSMutableArray *people;
ViewController.m:
@implementation PeopleViewController
@synthesize people;
In viewDidLoad:
- (void)viewDidLoad {
[super viewDidLoad];
// initialize our people array with an autoreleased object
people = [NSMutableArray array];
... Populate the people array with Person objects.
}
當我在那裏,我修改了的tableview一個單元格的內容來看,我輸入「PO self.people」當我無法訪問在gdb人陣:
Person *person = [[Person alloc] init];
person = [self.people objectAtIndex: indexPath.row]; // <--- 'po self.people' called
cell.textLabel.text = person.personName;
任何想法爲什麼我無法訪問它?
我不認爲需要保留消息,因爲該屬性被標記爲「保留」。 – 2010-01-05 17:06:25
但是這裏沒有使用屬性,實例變量直接被訪問,所以屬性沒有關係。 – jbrennan 2010-01-05 17:09:12
正如jbrennan所說:self.person意味着對屬性setter方法的調用,而「person」本身就是對ivar的賦值。 – 2010-01-06 07:35:08