标签:style ar sp for strong on log bs ef
字符串的截取主要2种方式:(URL格式的字符 不能截取 必须专程字符串才能截取)
//取出图片的url地址
NSURL *url=[info objectForKey:UIImagePickerControllerReferenceURL];
NSLog(@"qqqq:%@",url);
qqqq:assets-library://asset/asset.JPG?id=3D3341A0-403D-488C-8C57-69573C779ABD&ext=JPG
//把URL转换成字符串格式 才能截取
NSString *string = [[url absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
1.截取从某个下标开始到最后 以及从开始到某个下标 的自字符串
//从某个下标截取到末尾的子字符串
// NSString *str1 = [string substringFromIndex:36];
NSLog(@"x≈%@",string);
x≈assets-library://asset/asset.JPG?id=3D3341A0-403D-488C-8C57-69573C779ABD&ext=JPG
2. 截取两个字符之间的 一段子字符串
NSArray *array=[string componentsSeparatedByString:@"="];
NSString *str1=array[1];
NSLog(@"截取后的字符串:%@",str1);
截取后的字符串:3D3341A0-403D-488C-8C57-69573C779ABD&ext
//保存图片至本地 (自己写的方法)
[self saveImage:image withName:str1];
标签:style ar sp for strong on log bs ef
原文地址:http://www.cnblogs.com/luningning0901/p/4155107.html