cyclingIsBetter
cyclingIsBetter

Reputation: 17591

IOS: handle nsstring

I have two problem:

first:

I have a NSSTring as @"abcdef\n" , I want to delete from this string "\n", how can I do?

second:

if I have a string as @"abcdef \n", I don't know how is long space, but I want only text of this nsstring

thanks

Upvotes: 1

Views: 215

Answers (2)

unexpectedvalue
unexpectedvalue

Reputation: 6139

[@"abcdef\n" stringByReplacingOccurrencesOfString:@"\n" withString:@""];
[@"abcdef \n" stringByReplacingOccurrencesOfString:@" " withString:@""];

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html

Upvotes: 2

Rens Verhage
Rens Verhage

Reputation: 5857

Just replace all occurrences of \n with empty string like this:

myString = [myString stringByReplacingOccurrencesOfString:@"\n" withString:@""];

Upvotes: 1

Related Questions