objective c - NSArray (and other Cocoa types) @property values -


while in process of debugging code written co-worker, stumbled across following has me mystified:

nsmutablearray *array = [nsmutablearray array]; nsuinteger arraycount = array.count; 

why work? works nsdictionary , other types, in documentation nor cocoa headers can @property definitions found.

googling "nsarray property" doesn't yield many useful results, i'm reaching out surely embarrassing question.

it works because dot syntax has nothing properties. syntactic sugar (though don't it, perhaps it's "syntactic salt").

when use dot syntax rvalue expression (or expression right of equal sign), simple turns:

bar = myobject.thing; 

into

bar = [myobject thing]; 

when dot left of equal sign (as lvalue), turns setter. so:

myobject.thing = 42; 

becomes

[myobject setthing:42]; 

so yes, can things myobject.retain. you should never ever that. should ever use dot syntax accessors declared properties (ie, things have been explicitly declared via @property). <insert remark how should never use dot syntax @ all.>

for more information, checkout out the documentation on dot syntax (specifically "incorrect use" section).


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -