objective c - NSKeyedArchiver with pointers -


hi if want archive structure pointers in it, 2 different pointers point same place, after encoding-decoding point same place?

sorry bad english, , thx ahead answers , free time!

yes. if have 2 keys point same object, nskeyarchiver restore them keys pointing same object.

nsstring *one = @"1"; nsstring *two = @"2"; nsmutabledictionary *dict = [[[nsmutabledictionary alloc] initwithobjectsandkeys:one, @"one", two, @"two", one, @"three", nil] autorelease]; nslog(@"one=%d, two=%d, three=%d", [[dict objectforkey:@"one"] hash], [[dict objectforkey:@"two"] hash], [[dict objectforkey:@"three"] hash]); nsdata *data = [nskeyedarchiver archiveddatawithrootobject:dict];  dict = nil; // no tricks!  dict = [nskeyedunarchiver unarchiveobjectwithdata:data];  nslog(@"one=%d, two=%d, three=%d", [[dict objectforkey:@"one"] hash], [[dict objectforkey:@"two"] hash], [[dict objectforkey:@"three"] hash]); 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -