objective c - Why does calling a property on NSObject pointer gives build errors? -
i have nsmutablearray
returns me object. object added had properties name,age.
now when use these properties on object returned (obj.name
or obj.age
), compiler says, no such member, use (->
) instead of (.
)
i understand nsobject wont have these members , hence wont understand property.
but if use setters, , getters method ([obj name]
or [obj age]
) syntax instead of properties, dont errors.
but using property means calling setter or getter ?
ad objective c suppose dynamic language, right ?
that's right - dot syntax not supported in such case.
you need cast pointer actual class:
((myobject*)[array objectatindex: 0]).name = @"bill";
Comments
Post a Comment