Note that there are some explanatory texts on larger screens.

plurals
  1. POBOOL becomes false after archiving array
    text
    copied!<p>I am trying to debug this app but there is one big problem. When I try to save my array to a data file everything is working. However if I close the app and reopen a boolean in the array becomes nil. Here is the code to save the array:</p> <pre><code>NSString *filePath = [self dataFilePath]; [NSKeyedArchiver archiveRootObject:self.alist toFile:filePath]; NSLog(@"%@", self.alist.description); - (NSString*)dataFilePath { NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *filePath = [docDir stringByAppendingPathComponent:@"AssignmentInfo.data"]; NSFileHandle *file = [NSFileHandle fileHandleForWritingAtPath:filePath]; if (!file) { if (![[NSFileManager defaultManager] createFileAtPath:filePath contents:nil attributes:nil]) { } else file = [NSFileHandle fileHandleForWritingAtPath:filePath]; } return filePath; } </code></pre> <p>Inside the array is a custom class I created... Here is the code for the class:</p> <pre><code>-(NSString *)description { NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init]; dateFormatter.timeZone = [NSTimeZone defaultTimeZone]; dateFormatter.timeStyle = NSDateFormatterShortStyle; dateFormatter.dateStyle = NSDateFormatterShortStyle; NSString *dateTimeString = [dateFormatter stringFromDate: self.dateTime]; return [NSString stringWithFormat:@"Class: %@\r Assignment Title: %@ \rAssignment Description: %@ \rDue: %@ \r%s", self.className, self.assignmentTitle, self.assignmentDescription, dateTimeString,self.notifcationStatus ? "Notification On" : "Notification Off"]; } -(id)initWithCoder:(NSCoder *)aDecoder { self = [super init]; self.className = [aDecoder decodeObjectForKey:@"className"]; self.assignmentTitle = [aDecoder decodeObjectForKey:@"assignmentTitle"]; self.assignmentDescription = [aDecoder decodeObjectForKey:@"assignmentDescription"]; self.dateTime = [aDecoder decodeObjectForKey:@"dateTime"]; self.notifcationStatus = [aDecoder decodeBoolForKey:@"notifcationStatus"]; return self; } -(void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:self.className forKey:@"className"]; [aCoder encodeObject:self.assignmentTitle forKey:@"assignmentTitle"]; [aCoder encodeObject:self.assignmentDescription forKey:@"assignmentDescription"]; [aCoder encodeObject:self.dateTime forKey:@"dateTime"]; [aCoder encodeBool:self.notifcationStatus forKey:@"notificationStatus"]; } </code></pre> <p><code>self.notifcationStatus</code> is the array that becomes <code>FALSE</code>.</p>
 

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