从iOS中的字符串中删除括号

lak*_*esh 2 objective-c ios

我试图删除iOS中我的字符串中的所有括号.看到这个stackoverflow帖子:如何删除空格,括号和"来自nsarray

答案:

NSCharacterSet *charsToTrim = [NSCharacterSet characterSetWithCharactersInString:@"()"];
s = [s stringByTrimmingCharactersInSet:charsToTrim];
Run Code Online (Sandbox Code Playgroud)

但这只是删除一个括号(来自mystring.如何删除所有这些?

我的代码看起来像这样:

NSCharacterSet *charsToTrim = [NSCharacterSet characterSetWithCharactersInString:@"( )"];
attributedLabel.text = [attributedLabel.text stringByTrimmingCharactersInSet:charsToTrim];
NSLog(@"%@",attributedLabel.text);
Run Code Online (Sandbox Code Playgroud)

需要一些指导......

Vin*_*yne 15

请尝试使用
[[attributedLabel.text stringByReplacingOccurrencesOfString:@"(" withString:@""] stringByReplacingOccurrencesOfString:@")" withString:@""];
.