Bilal
Bilal

Reputation: 141

Parsing a string with Objective-C

How to parse an xcode url and get data that returns i.e

1

bilal

engineer

to different xcode fields i.e

NSString *id=1
NSString *name=bilal
NSString *designation=engineer

note. my url is self constructed to simply return the fields

Upvotes: 0

Views: 1932

Answers (1)

Julio Gorgé
Julio Gorgé

Reputation: 10106

I don't know if you are already establishing a connection to your web service or not… if not look up NSURLConnection in Google or Stack Overflow.

Regarding the only part of your question that I understood:

NSString* result = @"1\nbilal\nengineer";
NSArray* components = [result componentsSeparatedByString:@"\n"];

NSString* id = [components objectAtIndex:0];
NSString* name = [components objectAtIndex:1];
NSString* designation = [components objectAtIndex:2];

Upvotes: 2

Related Questions