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
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.
How about stringByTrimmingCharactersInSet: method? By stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet], it can remove both ends of whitespace and newline characters.