我从服务器收到 Json 响应。
type = 2;
"daysofWeek" = "(\n Mon,\n Tue\n)";
serviceType = 2;
startDate = "2013-10-28";
在上述格式中,daysofWeek 是数组字符串。我正在尝试将 NSMutableArray 转换为
NSString *weekDaysStr=[valueDict objectForKey:@"recrWeek_daysofWeek"];
NSMutableArray *weekDays=[[NSMutableArray alloc] initWithArray:[weekDaysStr componentsSeparatedByString:@","]];
但是当我记录这个数组时,我显示为
("\n Mon",
"\n Tue\n"
)
如何从数组中删除那些多余的单词。
我已经检查了工作日的每个值。
NSString *day=@"Mon";
if([day isEqualToString:[weekDays objectAtIndex:0]){
}
我也试过这种类型
weekDaysStr=[weekDaysStr stringByReplacingOccurrencesOfString:@"(\n" withString:@""];
weekDaysStr=[weekDaysStr stringByReplacingOccurrencesOfString:@"\n)" withString:@""];
weekDaysStr=[weekDaysStr stringByReplacingOccurrencesOfString:@"\n " withString:@""];
weekDaysStr=[weekDaysStr stringByReplacingOccurrencesOfString:@" " withString:@""];
weekDaysStr=[weekDaysStr stringByReplacingOccurrencesOfString:@"\"" withString:@""];
weekDaysStr=[weekDaysStr stringByReplacingOccurrencesOfString:@" " withString:@""];
它显示为
"Mon",
Tue
当时它给出了错误的条件。帮我解决这个问题