• 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: Dictionary not returning objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dictionary not returning objects


  • Subject: Re: Dictionary not returning objects
  • From: Dave Zarzycki <email@hidden>
  • Date: Sun, 15 Apr 2012 17:25:35 -0400

On Apr 15, 2012, at 3:46 PM, Markus Spoettl <email@hidden> wrote:

> On 4/15/12 8:06 PM, Scott Ribe wrote:
>> On Apr 15, 2012, at 12:01 PM, Markus Spoettl wrote:
>>
>>> I have an NSDictionary that contains, well, objects. When I call -objectForKey: I get nil for keys that are definitely in there.
>>>
>>> The dictionary gets constructed like this:
>>>
>>>  [NSDictionary dictionaryWithObjectsAndKeys:
>>>      kUnitsKey, [NSNumber numberWithDouble:units],
>>>      kValueKey, [NSNumber numberWithDouble:value],
>>>      kIsMetricKey, [NSNumber numberWithBool:isMetric],
>>>      nil];
>>
>> You've switch the order of objects&  keys in the arguments.
>
> OMG. Worst. mistake. ever. I'll be embarrassed for one week, I promise.


If you can use the Xcode 4.4 beta, then you can define away this mistake entirely:

NSDictionary *dict = @{
	kUnitsKey : [NSNumber numberWithDouble:units],
	kValueKey : [NSNumber numberWithDouble:value],
	kIsMetricKey : (isMetric ? @YES : @NO)
};

See this web page for more info:

	http://clang.llvm.org/docs/ObjectiveCLiterals.html


davez
_______________________________________________

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: 
 >Dictionary not returning objects (From: Markus Spoettl <email@hidden>)
 >Re: Dictionary not returning objects (From: Scott Ribe <email@hidden>)
 >Re: Dictionary not returning objects (From: Markus Spoettl <email@hidden>)

  • Prev by Date: Re: Webview cache location
  • Next by Date: Re: Responder chain inclarity
  • Previous by thread: Re: Dictionary not returning objects
  • Next by thread: Re: Dictionary not returning objects
  • Index(es):
    • Date
    • Thread