개체를 plist 파일에 보관하고 나중에 tableView를 채우기 위해로드하려고했습니다. 파일이 올바르게 보관 된 것으로 보이지만 파일에서 값을 가져 오려고 할 때 잘못된 액세스가 발생합니다.NSKeyedUnarchiver - 액세스 권한이 잘못되었습니다
내가 잘못 했나요?
이 내가 내가 빌드 할 경우
- (void)viewDidLoad {
// Load Phone Book
NSArray *arr = [NSKeyedUnarchiver unarchiveObjectWithFile:@"phonebook.plist"];
self.list = arr;
[arr release];
[super viewDidLoad];
}
부분 파일에서 그것을 얻을 배열로 다시 저장하려고 여기
// Create some phonebook entries and store in array
NSMutableArray *book = [[NSMutableArray alloc] init];
Phonebook *chris = [[Phonebook alloc] init];
chris.name = @"Christian Sandrini";
chris.phone = @"1234567";
chris.mail = @"[email protected]";
[book addObject:chris];
[chris release];
Phonebook *sacha = [[Phonebook alloc] init];
sacha.name = @"Sacha Dubois";
sacha.phone = @"079 777 777";
sacha.mail = @"[email protected]";
[book addObject:sacha];
[sacha release];
Phonebook *steve = [[Phonebook alloc] init];
steve.name = @"Steve Solinger";
steve.phone = @"079 123 456";
steve.mail = @"[email protected]";
[book addObject:steve];
[steve release];
[NSKeyedArchiver archiveRootObject:book toFile:@"phonebook.plist"];
를 저장하고있는 곳입니다 세포
다음- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *PhoneBookCellIdentifier = @"PhoneBookCellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:PhoneBookCellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:PhoneBookCellIdentifier] autorelease];
}
NSUInteger row = [indexPath row];
Phonebook *book = [self.list objectAtIndex:row];
cell.textLabel.text = book.name;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
return cell;
}
나쁜 액세스 오류
현재 언어 : 자동; 현재 목표 - C 어설 션 실패 : (CLS), 기능 getName, 파일 /SourceCache/objc4_Sim/objc4-427.5/runtime/objc-runtime-new.mm, 라인은 3990 어설 션 실패 : (CLS), 기능을 getName, /SourceCache/objc4_Sim/objc4-427.5/runtime/objc-runtime-new.mm 파일, 라인은 3990 어설 션 실패 : (CLS), 기능 getName, /SourceCache/objc4_Sim/objc4-427.5/runtime 파일 /objc-runtime-new.mm, 라인 3990 어설 션 실패 : (CLS), 기능 getName, 파일 /SourceCache/objc4_Sim/objc4-427.5/runtime/objc-runtime-new.mm, 라인 3990
I을 이것이 유일한 문제인지 확실하지 않지만 viewDidLoad에서 arr을 해제해서는 안됩니다. – walkytalky