iOS之OC随笔-Foudation框架下集合的相互转换
2015-10-13 21:01
435 查看
#import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { //1、NSArray 转换为 NSMutableArray NSArray * array = @[@"One",@"Two",@"Three"]; NSMutableArray * muArray = [NSMutableArray arrayWithArray:array]; NSLog(@"muArray %@",muArray); //2、NSDictionary 转换为 NSMutableDictionary NSDictionary * dic = @{@"One":@"1",@"Three":@"3"}; NSMutableDictionary * mudic = [NSMutableDictionary dictionaryWithDictionary:dic]; NSLog(@"muDic %@",mudic); //3、NSSet 转换为 NSMutableSet NSSet * set = [[NSSet alloc]initWithObjects:@"One",@"Two", nil]; NSMutableSet * muSet = [NSMutableSet setWithSet:set]; NSLog(@"muSet %@",muSet); //4、NSArray 转换为 NSMutableSet NSMutableSet * muSet2 = [NSMutableSet setWithArray:array]; NSLog(@"muSet2 %@",muSet2); //5、NSDictionary 转换为 NSArray NSArray * allkeys = [dic allKeys]; NSLog(@"allkeys %@",allkeys); NSArray * allValues = [dic allValues]; NSLog(@"allvalue %@",allValues); //6、字符串转换为数组 NSString * str = @"sae.fasfas"; NSArray * strArray = [str componentsSeparatedByString:@"."]; NSLog(@"strArray %@",strArray); } return 0; }
相关文章推荐
- iOS 地图
- iOS 创建单例的两种方法
- iOS之OC随笔-遍历数组方法总结
- iOS之CocoaPods 安装
- IOS contentMode属性
- 蓝懿iOS 技术内容和心得 10。13
- ios学习之模糊效果的学习
- iOS序列化与反序列化
- iOS之OC随笔-属性修饰符
- iOS 常用名词
- iOS第三方库
- IOS下自定义click事件使用alert引发的血案
- iOS实现地图半翻页效果--老代码备用参考
- IOS导航控制器的手势滑动后退
- iOS多线程之GCD
- ios 关于AleartView 自动取消的问题
- ios音频视频资料--备用
- iOS隐藏导航栏或返回按钮
- iOS-跨界面传值和跨应用传值
- ios coredata 老代码备用参考