iOS KVC valueForKeyPath学习心得
2016-01-16 14:06
435 查看
#import <Foundation/Foundation.h> @interface myClass1 : NSObject @property (nonatomic, copy) NSString *str; @end @implementation myClass1 @end @interface myClass : NSObject { } @property (nonatomic, retain) myClass1 *item; @end @implementation myClass - (id)init{ if(self = [super init]){ [self setValue:[[myClass1 alloc]init] forKey:@"item"];//如果不给item设置值,则最后得到的item.str为空! } return self; } @end int main(int argc, const char * argv[]) { @autoreleasepool { [class1 setValue:@"this is item.str" forKeyPath:@"item.str"]; NSLog(@"item.str = %@",[class1 valueForKeyPath:@"item.str"]); } return 0; } 高级用法:http://www.thinksaas.cn/group/topic/347021/
相关文章推荐
- 第八章 ArrayBlockingQueue源码解析
- Dynamic Programming--Longest Common Subsequence
- IOS UITextField &UITextView
- A Better solution for the Windows 7 SP1 ADO GUID changes
- UISearchBar总结
- iOSUI-导航控制器全屏滑动返回效果
- iOS UI-自动布局(Autoresizing)
- 从UIImage的矩阵变换看矩阵运算的原理
- UITextField 光标的位置设置获取
- 213,使用UINavigationController实现页面跳转
- easyui 在tabs子页面关闭当前tabs
- iOS 开发学习之 User Interface(3)iOS 坐标系和 UILabel 与 UIButton
- iOS 开发学习之 User Interface(2)UIWindow 视窗
- fail to build phoneME Feature-转
- iOS 开发学习之 User Interface(3)iOS 坐标系和 UILabel 与 UIButton
- QQ互联登陆出现(1054) Unknown column “conuintoken” in “field list”
- workqueue机制分析之wb_workfn函数
- UIAlertView -(警告框)方法总结
- 【Android开发小记--2】百度外卖 UI界面
- 微信官方UI库—WeUI