Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't write dictionary to plist objective c
    primarykey
    data
    text
    <p>Through searching the internet I have come up with some code that should retrieve data from a plist and write data to a plist. I can retrieve data just fine but storing data isn't working. Here is my store Data method:</p> <pre><code>- (void)saveData { [self.time setObject:[NSNumber numberWithInt:self.brace.timeOutOfBrace.todayHours] forKey:@"TimeOutOfBraceHours"]; [self.time setObject:[NSNumber numberWithInt:self.brace.timeOutOfBrace.todayMinutes] forKey:@"TimeOutOfBraceMinutes"]; [self.time setObject:[NSNumber numberWithInt:self.brace.timeOutOfBrace.overallHours] forKey:@"OverallHours"]; [self.time setObject:[NSNumber numberWithInt:self.brace.timeOutOfBrace.overallMinutes] forKey:@"OverallMinutes"]; [self.time setObject:[NSNumber numberWithInt:self.brace.timeOutOfBrace.goalForWeek] forKey:@"WeeklyGoal"]; NSString *plistCatPath = [[NSBundle mainBundle] pathForResource:@"Property List" ofType:@"plist"]; NSMutableDictionary *rootDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:plistCatPath]; [rootDictionary setObject:self.time forKey:@"Time"]; [rootDictionary writeToFile:plistCatPath atomically:YES]; } </code></pre> <p>The NSMutableDictionary</p> <pre><code>self.time </code></pre> <p>is declared in the implementation.</p> <p>Here is the read data method:</p> <pre><code>- (void)retreiveData { NSString *plistCatPath = [[NSBundle mainBundle] pathForResource:@"Property List" ofType:@"plist"]; NSMutableDictionary *rootDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:plistCatPath]; self.time = rootDictionary[@"Time"]; NSLog(@"%@", self.time[@"TimeOutOfBraceHours"]); self.brace.timeOutOfBrace.todayHours = [[self.time objectForKey:@"TimeOutOfBraceHours"] intValue]; self.brace.timeOutOfBrace.todayMinutes = [[self.time objectForKey:@"TimeOutOfBraceMinutes"] intValue]; self.brace.timeOutOfBrace.overallHours = [[self.time objectForKey:@"OverallHours"] intValue]; self.brace.timeOutOfBrace.overallMinutes = [[self.time objectForKey:@"OverallMinutes"] intValue]; self.brace.timeOutOfBrace.goalForWeek = [[self.time objectForKey:@"WeeklyGoal"] intValue]; } </code></pre> <p>When I run the program it just retrieves the data that I manually put into the plist instead of the data that was supposedly stored in it on the last run.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    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