开发者

Is there a way in Objective-C to set a property value without directly invoking the setter?

Is there a way in Objective-C to set a property value 开发者_高级运维of a class instance X without directly invoking the setter, but just somehow specifying the property name ?

I have a NSDictionary in which the keys are the property names and the values are the values to assign.

Now I just would like to iterate my NSDictionary and set the property of the instance X by just specifying the key.

I hope it is clear... thanks


You can do this using Key Value Coding. Just use the setValue:forKey: and valueForKey: methods to set and get properties. Behind the scenes those will use the setters if available, but they also can access ivars directly, if there are no accessors.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜