NSCharacterSet* nonDigits =[[NSCharacterSet decimalDigitCharacterSet] invertedSet];
int remainSecond =[[jsonObject[@"message"] stringByTrimmingCharactersInSet:nonDigits] intValue];
转载于:https://my.oschina.net/wupengnash/blog/509232
本文介绍了一个Objective-C中处理字符串去除数字的方法,通过使用NSCharacterSet和invertedSet来创建一个非数字字符集,然后利用该字符集对从jsonObject中获取的message字段进行trimming操作,最终转换为整数。
NSCharacterSet* nonDigits =[[NSCharacterSet decimalDigitCharacterSet] invertedSet];
int remainSecond =[[jsonObject[@"message"] stringByTrimmingCharactersInSet:nonDigits] intValue];
转载于:https://my.oschina.net/wupengnash/blog/509232
695
3892
2127

被折叠的 条评论
为什么被折叠?
