• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Encoding infinite loops
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Encoding infinite loops
      • From: Chris Kane <email@hidden>
    • Re: Encoding infinite loops
      • From: Jonathon Mah <email@hidden>
  • Prev by Date: Re: Problem scrolling a clip view
  • Next by Date: notifications
  • Previous by thread: Using transformed value for sorting table column
  • Next by thread: Re: Encoding infinite loops
  • Index(es):
    • Date
    • Thread