nsmutabledictionary - What does this Objective-C code snippet mean, and what document details it? -
ok, i've done searches in xcode, on apple's developer's site, , on google, , have downloaded , searched pdf versions of key-value coding programming guide , collections programming topics, cannot find syntax listed anywhere. second line of following snippet do, , can find details on it?
nsmutabledictionary *change = [nsmutabledictionary new]; change[@(somevariable)] = @(someothervariable);
i don't know if i'm having brain fart, or if i've never seen before, bugs me can't find documentation it.
there 2 things going on here:
dictionary (and array) subscripting
change[key]
this new syntactic sugar for
[change objectforkey:key]
or, if used lvalue, syntactic sugar for
[change setobject:value forkey:key]
for what's going on here (
objectforkeyedsubscript:
,setobject:forkeyedsubscript:
) see http://www.apeth.com/iosbook/ch10.html#_nsdictionary_and_nsmutabledictionarynumber literals
@(somevariable)
this new compiler directive, equivalent to:
[nsnumber numberwithint: somevariable]
except in fact use
numberwithint:
,numberwithfloat:
, or whatever appropriate based on type ofsomevariable
.
Comments
Post a Comment