Reputation: 73
I'm parsing an XML and saving result to NSMutableArray. When I do NSLog,
NSLog(@"Data : %@",_data);
I'm getting
Data : (
{
SessionToken = 9e72dd029e0e8268380b919356881935;
}
)
I only want 9e72dd029e0e8268380b919356881935 from the array. What is the best solution to achieve this?
EDIT : There will be only one SessionToken at a time.
Upvotes: 0
Views: 1175
Reputation: 3888
for (NSDictionary *data1 in _data) {
NSlog("session token %@",[data1 valueForKey:@"SessionToken"]);
}
Upvotes: 0
Reputation: 769
if ([_data count]) {
NSDictionary *dic = [_data objectAtIndex:0];
NSLog(@"Data : %@",[dic objectForKey:@"SessionToken"]);
}
Upvotes: 1
Reputation: 17585
You can try this code :
for (NSDictionary *data1 in _data) {
NSlog("session token %@",[data1 objectForKey:@"SessionToken"]);//Other wise add into another array which contain session token.. only..
}
Upvotes: 6
Reputation: 10201
Since there will be only one session at a time.
NSDictionary *session = [_data lastObject];
NSString *sessionToken = session[@"SessionToken"];
OR with literals
NSString *sessionToken = _data[0][@"SessionToken"];
Upvotes: 1