-2

I get a response value from PHP code that goes like that:

"success, 32"

How can I display in NsLog the first part of the value before the - "," and the second part separately?

  • If those quotation marks are part of the response you get from the PHP code, you might want to trim them off before calling componentsSeparatedByString. E.g. `NSString *trimmedString = [string stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"\" "]];` – Rob May 27 '14 at 19:27

1 Answers1

0

Break the string into an array of chunks:

NSArray *chunks = [string componentsSeparatedByString: @","];

then display the chunk you want:

NSLog(@"%@", chunks[0]);

or

NSLog(@"%@", chunks[1]);
Shane
  • 972
  • 2
  • 12
  • 27
  • Consider accepting answers that are helpful, it rewards the people who take the time to answer and increases your reputation. Click on the hollow checkmark next to the answer that is best. [See this page for more detail](http://meta.stackoverflow.com/questions/5234/how-does-accepting-an-answer-work). – zaph May 27 '14 at 18:49