[示例]NSDictionary-存数据到字典及@(xxx)强转为对象的用法
代码:
#import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { NSString *name=@"wangchongyang"; NSInteger age=56; NSString *work=@"daozhang"; NSDictionary *dic=@{@"name":name, @"age":@(age), //将NSInteger强制转换为对象 @"work":work}; NSLog(@"name:%@,age:%@,work:%@",dic[@"name"],dic[@"age"],dic[@"work"]); NSMutableDictionary *dic2=[[NSMutableDictionary alloc]init]; [dic2 setDictionary:@{@"name":@"wangyang"}]; NSLog(@"%@",dic2); } return 0; }