0

I have some NSMutableArray of objects which are classes of mine that represent some data structure.

I am trying to save that array of objects to the user defaults, but i can see its not being saved.

I wonder, if the fact the the objects in there are instances of my own classes, and not some pointers to specific images .

//create an object of my class and add to the array
  Task *firstTask=[[Task alloc] initWithTag:@"A" AndColor:@"B" AndText:@"C" Done:0];
    [self.tasks addObject:firstTask]; //add to array 

//save to defaults
 [[NSUserDefaults standardUserDefaults]setObject:self.tasks forKey:@"tasks"];
 [[NSUserDefaults standardUserDefaults]synchronize];

//retrieve (get null)
  self.tasks=[[NSMutableArray alloc] init] ;
  self.tasks=[[[NSUserDefaults standardUserDefaults]objectForKey:@"tasks"]mutableCopy];

all the mechanism works, till i am trying to save to defaults .

How do you save these kind of data (objects of my own classes )

Curnelious
  • 1
  • 16
  • 76
  • 150
  • Is `self.tasks` null? Or does it contain an object and that object is null? What does `NSLog(@"%d", [self.tasks count]);` return after you retrieve? And what does `NSLog(@"%@",self.tasks); return? – nhgrif Jan 12 '14 at 20:21
  • 1
    NSCoding. initWithCoder. encodeWithCoder. NSKeyedArchiver/NSKeyedUnarchiver – Evgeniy S Jan 12 '14 at 20:25
  • @JoshCaswell i get null for the log of self.tasks . evgeniy- what???? – Curnelious Jan 12 '14 at 20:44

0 Answers0