• 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
@distinctUnionOfObjects changes the order of objects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

@distinctUnionOfObjects changes the order of objects?


  • Subject: @distinctUnionOfObjects changes the order of objects?
  • From: Harilaos Skiadas <email@hidden>
  • Date: Mon, 20 Dec 2004 14:03:21 -0800 (PST)
  • Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys

Hi all,

   I have the following relatively simple problem. I
have an NSArray that has two entries. Each entry is a
dictionary with two keys, @"ProgramCode" and
@"ProgramName". Actually it has more keys, but let's
not worry about them. The values of both keys are
NSStrings. What I want is, given a string aCode, much
aCode among the @"ProgramCode" key in the matrix, and
return the corresponding value of the key
@"programName". In my case in particular, lets say
that the first entry of the array has
ProgramCode="MCLY" and programName="Macaulay 2", while
the second entry has ProgramCode="PARI" and
programName="PARI/GP". What I thought should work was:

NSArray *codeList = [myArray
valueForKeyPath:@"@distinctUnionOfObjects.ProgramCode"];
unsigned int indexOfCode = [codeList
indexOfObject:aCode];
NSString *aProgramName = [[myArray
objectAtIndex:index] valueForKey:@"ProgramName"];

What happens when I try to debug this, is that
codeList contains the codes in the reverse order than
the order they appeared in the array, i.e. PARI comes
first, and MCLY second. Of course the result of this
is that the index information I get out of this is
useless.
Is this something to be expected? I can't rely on
@distinctUnionOfObjects not to mess up the order of
things?
Is there a better way to accomplish what I am trying
to do, without actually writing my own loop that goes
through the array entries?

Haris




__________________________________
Do you Yahoo!?
Meet the all-new My Yahoo! - Try it today!
http://my.yahoo.com


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: @distinctUnionOfObjects changes the order of objects?
      • From: Scott Anguish <email@hidden>
  • Prev by Date: Re: How to animate NSTableView row reordering
  • Next by Date: Current tick mark index of NSSlider?
  • Previous by thread: Re: Anybody knows how to port PCI device drivers to OSX
  • Next by thread: Re: @distinctUnionOfObjects changes the order of objects?
  • Index(es):
    • Date
    • Thread