NSString: EOL and rangeOfString issues

Posted by carloe on Stack Overflow See other posts from Stack Overflow or by carloe
Published on 2010-06-10T21:13:15Z Indexed on 2010/06/11 1:32 UTC
Read the original article Hit count: 304

Filed under:
|
|

Could someone please tell me if I am missing something here... I am trying to parse individual JSON objects out of a data stream. The data stream is buffered in a regular NSString, and the individual JSON objects are delineated by a EOL marker.

if([dataBuffer rangeOfString:@"\n"].location != NSNotFound) {
  NSString *tmp = [dataBuffer stringByReplacingOccurrencesOfString:@"\n" withString:@"NEWLINE"];
  NSLog(@"%@", tmp);
 }

The code above outputs "...}NEWLINE{..." as expected. But if I change the @"\n" in the if-statement above to @"}\n", I get nothing.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about nsstring