Encoding infinite loops
Encoding infinite loops
- Subject: Encoding infinite loops
- From: Will Thimbleby <email@hidden>
- Date: Mon, 21 May 2007 15:15:14 +0100
I'm having trouble encoding this array containing an infinite loop:
NSMutableArray *a = [[NSMutableArray alloc] init];
[a addObject:a];
Yes I'm using NSKeyedArchiver and I've tried various ways of encoding
the array, but when decoded none of the arrays are correct. Here's my
current test code:
NSMutableArray *a = [[NSMutableArray alloc] init];
[a addObject:a];
NSLog(@"%d, %d", a, [a lastObject]);
NSMutableData *data = [[NSMutableData alloc] init];
NSKeyedArchiver *ka = [[NSKeyedArchiver alloc]
initForWritingWithMutableData:data];
[ka encodeObject:a];
[ka finishEncoding];
NSKeyedUnarchiver *ku = [[NSKeyedUnarchiver alloc]
initForReadingWithData:data];
a = [ku decodeObject];
[ku finishDecoding];
NSLog(@"%d, %d", a, [a lastObject]);
The last object of the array "a" is uninitalised and useless. Any
ideas welcome.
cheers
--Will
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden