1 字符串轉數(shù)組
將string字符串轉換為array數(shù)組
NSString *str = [NSString stringWithFormat:@"A8ENKIL5BCSSD5S32DFWEAE==,20180507"];
//將array數(shù)組轉換為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;
}