to trim spaces an \n from NSString

孤者浪人 提交于 2020-01-03 12:35:33

问题


I have NSString @" (\n "Bi_ss" \n) " I want to get String @"Bi_ss "

Any one has any idea about this ? Thank you


回答1:


NSString *trimmedString = [string stringByTrimmingCharactersInSet:
                                  [NSCharacterSet whitespaceAndNewlineCharacterSet]];

From Cocoanetics...




回答2:


Take a look at the NSString method stringByReplacingOccurrencesOfString:withString for example, this should be able to perform the basic task you want it to do.



来源:https://stackoverflow.com/questions/9431026/to-trim-spaces-an-n-from-nsstring

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!