【发布时间】:2013-03-07 09:34:47
【问题描述】:
我想要完成的,我已经定义了一个宏,
#define NAME_List @"a,aaa,aac,aacaaba,abbbb"
我正在使用componentsSeperatedByString: 将其转换为NSArray,它可以为我提供NSString 对象的数组,而不是我想要NSDictionary 对象之类的东西,
[0] -> "名称" = "a"
[1] -> “名称” = “aaa”
[2] -> "名称" = "aac""
&不喜欢,
[0] -> 一个 [1]->aaa [2]->aac
我试过这个(但我不知道 NSKeyedArchiver 或 NSPropertyListFormat 或
NSPropertyListSerialization类)
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:arrayNames];
NSError *error = nil;
NSPropertyListFormat plistFormat;
NSDictionary *temp = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListImmutable format:&plistFormat error:&error];
更新
我可以遍历数组并创建字典对象并将其添加到数组中以执行此操作,但我不想这样做!
是否有任何可用的功能可以做到这一点?
【问题讨论】:
-
你试过'[NSDictionary dictionaryWithKeys:someArray andValues:someOtherArray]'吗?无论如何,您都需要为您的字典指定键,afaik...
-
您确定要不使用循环/迭代/递归吗?
-
是的,如果可能的话!我正在寻找一些比循环更快的替代方案!我只显示了几个有问题的字符串,实际上有 72k+ 字符串
标签: ios nsstring nsarray nsdictionary