Get the Value of Array that contains A String in Objective-C
Posted
by
jaytrixz
on Stack Overflow
See other posts from Stack Overflow
or by jaytrixz
Published on 2012-09-21T09:29:43Z
Indexed on
2012/09/21
9:37 UTC
Read the original article
Hit count: 216
How can I get the value of an array that has one value which is a string in Objective-C? I'm actually getting confused on how to properly get the string value inside the array I'm accessing.
I'm getting the value of an array named "sMessage" that has one value of type NSString "success".
This is the response from the API:
({"sMessage":"success"})
I'm trying to get the value by using this code and logs it to the console:
NSArray *resultsArray = [json objectForKey:@"sMessage"];
NSString *loginResult = [[resultsArray valueForKey:@"sMessage"] lastObject];
NSLog(@"Result is: %@", loginResult);
© Stack Overflow or respective owner