• 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
Re: Very interesting ordering caveat with NSArray arrayWithObjects:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Very interesting ordering caveat with NSArray arrayWithObjects:


  • Subject: Re: Very interesting ordering caveat with NSArray arrayWithObjects:
  • From: Uli Kusterer <email@hidden>
  • Date: Sun, 5 Apr 2009 18:02:51 +0200

On 04.04.2009, at 02:30, Eric Hermanson wrote:
Now, one would expect that the array would contain:

	element 1: MyCounterInstance.oid=1
	element 2: MyCounterInstance.oid=2

However, this is NOT the case. Either the compiler or the runtime executes the SECOND call to [MyCounterClass newObject] FIRST, so the array actually contains:

	element 1: MyCounterInstance.oid=2
	element 2: MyCounterInstance.oid=1


Nothing to do with ObjC or NSArray. That's a part of the C standard left open to allow platform-specific optimizations. I've blogged about it in a simpler context here:

	http://zathras.de/blog-c-parameter-evaluation-order.htm

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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


References: 
 >Very interesting ordering caveat with NSArray arrayWithObjects: (From: Eric Hermanson <email@hidden>)

  • Prev by Date: Re: Need localization-proof method of transporting dates.
  • Next by Date: Re: NSXMLParser memory consumption
  • Previous by thread: Re: Very interesting ordering caveat with NSArray arrayWithObjects:
  • Next by thread: Re: Very interesting ordering caveat with NSArray arrayWithObjects:
  • Index(es):
    • Date
    • Thread