{
"north product 1" = "";
"north product 2" = "";
"north product 3" = "";
"north product 4" = "";
}
如何将此字符串从字典加载到数组需要存储北方产品1,北方产品2,北方产品3,北方产品4。?
答案 0 :(得分:2)
即使您之前没有使用NSDictionary
课程的经验,两分钟实际查看docs会给您答案
NSArray *keys = [yourDictionary allKeys];
如果您决定使用值而不是键
,还有匹配的allValues
方法
答案 1 :(得分:0)
考虑到我没有描述任何内存管理规则。
NSMutableArray *arr = [NSMutableArray array];
NSString *nProduct1 = [aDictionary valueForKey:@"north product 1"];
NSString *nProduct2 = [aDictionary valueForKey:@"north product 2"];
NSString *nProduct3 = [aDictionary valueForKey:@"north product 3"];
NSString *nProduct4 = [aDictionary valueForKey:@"north product 4"];
[arr addObject:nProduct1];
[arr addObject:nProduct2];
[arr addObject:nProduct3];
[arr addObject:nProduct4];