Kev*_*tre 2 cocoa objective-c key-value-coding
我有一些自动反序列化代码,它将使用KVC设置对象的属性.我需要为基元(int,double,float)添加反序列化支持,但我无法(或不确定如何)使用带有基元的" setValue:forKey: ".必须在运行时执行属性查找.有任何想法吗?谢谢.
When you obtain such a value through valueForKey:, it will box the value up for you in an NSNumber (or NSValue, for certain structure types) object.
You just need to do the same thing the other way: Box the desired value up yourself, and pass that object in. setValue:forKey: will unbox it before passing it to the property's accessor/storing it in the relevant ivar.
| 归档时间: |
|
| 查看次数: |
922 次 |
| 最近记录: |