I have this JSON data :
array: {
data = (
{
"com_id" = 1;
"com_name" = Apple;
},
{
"com_id" = 2;
"com_name" = "Google";
},
{
"com_id" = 3;
"com_name" = "Yahoo";
}
);
message = "Data found";
response = success;
}
here's my code to fetch that data :
NSURL * url = [[NSURL alloc] initWithString:@"https://jsonurlhere.com"];
// Prepare the request object
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReturnCacheDataElseLoad
timeoutInterval:30];
// Prepare the variables for the JSON response
NSData *urlData;
NSURLResponse *response;
NSError *error;
// Make synchronous request
urlData = [NSURLConnection sendSynchronousRequest:urlRequest
returningResponse:&response
error:&error];
// Construct a Array around the Data from the response
NSArray* object = [NSJSONSerialization
JSONObjectWithData:urlData
options:0
error:&error];
NSLog(@"array: %@", object);
now, I want to use that JSON data into my PickerView. how to change that JSON data into array so that I can load it to replace my existing array (self.nameCompany)?
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.nameCompany = @[@"Apple", @"Google", @"Yahoo"];
}