1 字符串转数组
将string字符串转换为array数组
NSString *str = [NSString stringWithFormat:@"A8ENKIL5BCSSD5S32DFWEAE==,20180507"];
//将array数组转换为string字符串
NSArray *array = [str componentsSeparatedByString:@","];
2 json字符串 转字典
+ (NSDictionary *)JsonStringToDictionary:(NSString *)jsonString {
if (jsonString == nil) {
return nil;
}
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError *err;
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData
options:NSJSONReadingMutableContainers
error:&err];
if(err) {
NSLog(@"json解析失败:%@",err);
return nil;
}
return dic;
}