Note that there are some explanatory texts on larger screens.

plurals
  1. PONSKeyedUnarchiver - Bad access
    primarykey
    data
    text
    <p>I was trying to archive an object into a plist file and load it later to fill a tableView. It seems that the file gets archived correctly but I get a bad access when trying to get the value out of the file.</p> <p>Am I doing something wrong?</p> <p>This is where I save it</p> <pre><code>// 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 = @"christian.sandrini@example.com"; [book addObject:chris]; [chris release]; Phonebook *sacha = [[Phonebook alloc] init]; sacha.name = @"Sacha Dubois"; sacha.phone = @"079 777 777"; sacha.mail = @"info@yzx.com"; [book addObject:sacha]; [sacha release]; Phonebook *steve = [[Phonebook alloc] init]; steve.name = @"Steve Solinger"; steve.phone = @"079 123 456"; steve.mail = @"steve.solinger@wuhu.com"; [book addObject:steve]; [steve release]; [NSKeyedArchiver archiveRootObject:book toFile:@"phonebook.plist"]; </code></pre> <p>And here I try to get it out of the file and save it back into an array</p> <pre><code>- (void)viewDidLoad { // Load Phone Book NSArray *arr = [NSKeyedUnarchiver unarchiveObjectWithFile:@"phonebook.plist"]; self.list = arr; [arr release]; [super viewDidLoad]; } </code></pre> <p>The part where I try to build a cell</p> <pre><code>- (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; } </code></pre> <p>Here the bad access error</p> <blockquote> <p>Current language: auto; currently objective-c Assertion failed: (cls), function getName, file /SourceCache/objc4_Sim/objc4-427.5/runtime/objc-runtime-new.mm, line 3990. Assertion failed: (cls), function getName, file /SourceCache/objc4_Sim/objc4-427.5/runtime/objc-runtime-new.mm, line 3990. Assertion failed: (cls), function getName, file /SourceCache/objc4_Sim/objc4-427.5/runtime/objc-runtime-new.mm, line 3990. Assertion failed: (cls), function getName, file /SourceCache/objc4_Sim/objc4-427.5/runtime/objc-runtime-new.mm, line 3990.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload