Get the Value of Array that contains A String in Objective-C
- by jaytrixz
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);