gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Deserializaton order


From: Frederic Stark
Subject: Re: Deserializaton order
Date: Mon, 04 Apr 2005 09:37:57 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031007

Frederico Muñoz wrote:

The problem I'm having is that when I deserialize the data into a NSDictionary 
to perform the copy operations that
> filenames appear in random order,

NSDictionary's keys are not oredered. You should order them yourself.

If alphabetical order is fine, then, instead of:

NSEnumerator *e = [theDict keyEnumerator];
NSString *thePath;

while ((thePath = [e nextObject]))
  // Do something with [theDict objectForKey:thePath];


Use:

NSEnumerator *e = [[[theDict allKeys]
                      sortedArrayUsingSelector:@selector(compare:)]
                          objectEnumerator];
NSString *thePath;

while ((thePath = [e nextObject]))
  // Do something with [theDict objectForKey:thePath];

Cheers,

--fred






reply via email to

[Prev in Thread] Current Thread [Next in Thread]