我有一个数组,我试图从nsarray删除访问空间,方括号和“,以便使用componentsSeparatedByString:@";"
NSArray *paths = [dic valueForKey:@"PATH"];
for(NSString *s in paths)
{
NSLog(@"String: %@", s);
}
String: (
"29858,39812;29856,39812;29800,39819;29668,39843;29650,39847;29613,39855;29613,39855;29613,39856;29605,39857;29603,39867;29603,39867;29599,39892;29596,39909;29587,39957;29571,40018;29563,40038;29560,40043"
)
这是输出,显示有空格,方括号和“我如何删除它们
?
由于这行是该数组
"29858,39812;29856,39812;29800,39819;29668,39843;29650,39847;29613,39855;29613,39855;29613,39856;29605,39857;29603,39867;29603,39867;29599,39892;29596,39909;29587,39957;29571,40018;29563,40038;29560,40043" this line is a string inside the path array
内的字符串,我尝试使用componentsSeparatedByString:@";"
,所以不会溢出,所有里面都有空格括号和“。 最佳答案
尝试stringByTrimmingCharactersInSet:
NSCharacterSet *charsToTrim = [NSCharacterSet characterSetWithCharactersInString:@"() \n\""];
s = [s stringByTrimmingCharactersInSet:charsToTrim];