how to get rid of heading and trailing white spaces from NSString

前端 未结 2 764
北荒
北荒 2020-12-19 08:05

My NSString is like this:

NSString *myString =  
(  
“\\n \\n 24 K CLUB”,  
“\\n \\n 3 DOLLAR CAFE”,  
“\\n \\n A PEACH OF A PARTY”,  
“\\n \\n A ROYAL AFFAI         


        
2条回答
  •  無奈伤痛
    2020-12-19 08:49

    Your initial declaration of myString is declaring an NSArray, not a NSString. Your calls to stringByReplacingstringByReplacingOccurrencesOfString: withString: should work on the individual NSStrings. Either iterate the array yourself (see here) to trim the strings, or use makeObjectsPerformSelector: (see here) to handle it.

提交回复
热议问题