去除字符串中的特殊字符使用以下方法
stringByReplacingOccurrencesOfString:@" " withString:@""
使用如下
- (void)viewDidLoad {
[super viewDidLoad];
NSString *str = [self gainString:@"2017-04-29 01:12:30 +0000"];
NSLog(@"str===%@", str);
}
- (NSString *)gainString:(NSString *)string
{
NSString *result = [string stringByReplacingOccurrencesOfString:@" " withString:@""];
result = [result stringByReplacingOccurrencesOfString:@"-" withString:@""];
result = [result stringByReplacingOccurrencesOfString:@":" withString:@""];
NSLog(@"result===%@", result);
return result;
}