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:

  1. 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_nsmutabledictionary

  2. number literals

    @(somevariable) 

    this new compiler directive, equivalent to:

    [nsnumber numberwithint: somevariable] 

    except in fact use numberwithint:, numberwithfloat:, or whatever appropriate based on type of somevariable.

    again, see http://www.apeth.com/iosbook/ch10.html#_nsnumber


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -