I have a drawing app where paths are saved when the user draws and loaded back in when the user closes and re-opens the app.
I am adding objects (the brush colours) to an NSMutableArray then saving them like so:
// Adding object to NSMutableArray (this is in touchesMoved)
NSData *colorData = [NSKeyedArchiver archivedDataWithRootObject:self.brushColor];
[self.brushColours addObject:colorData];
// Saving array (this is in touchesEnded)
[defaults setObject:self.brushColours forKey:[NSString stringWithFormat:@"%@BrushColours%@", currentid, pageno]];
[defaults synchronize];
That's all fine and dandy, but when I try to load the paths back in and set their colours, this happens:
Why is this happening?
Edit: I'm loading the colours back in like this (this is in a for loop for each path):
NSMutableArray *arr3 = [defaults objectForKey:[NSString stringWithFormat:@"%@BrushColours%@", currentid, pageno]];
self.brushColor = [NSKeyedUnarchiver unarchiveObjectWithData:[arr3 objectAtIndex:index]];