Objective C can not process 2d array .count? -


i've got latest xcode xcode 4.6, , have problem:

nsarray *array = @[@[@"a",@"b"]]; nslog(@"%d", array[0].count); 

before run it, xcode told me "property 'count' not found on object of type 'id'".


but if change to

nslog(@"%d", [array[0] count]); 

then, fine.


so question is, why can't obj-c process two_d_array[index].count ?

looks @ docs nsarray. there no count property. in fact, there no properties @ nsarray.

when use property syntax non-property method, compiler deal ok if have object of specific type , there method of same name. in case have id. compiler can't safely work out attempt access count property should converted call count method.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Socket.connect doesn't throw exception in Android -

SPSS keyboard combination alters encoding -