Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9026299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:29:05+00:00 2026-06-16T06:29:05+00:00

I have to following JSON response from a server: { theSet: [ ], Identifikation:

  • 0

I have to following JSON response from a server:

   {
  "theSet": [

  ],
  "Identifikation": 1,
  "Name": "Casper",
  "Adress": "Lovis 23",
  "Location": "At home",
  "Information": "The first, the second and the third",
  "Thumbnail": "none",
 }

I am retrieving the data like so:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {

    NSLog(@"connectionDidFinishLoading");

    NSLog(@"Succeeded! Received %d bytes of data",[data length]);

    NSError *myError = nil;

     NSDictionary *res = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&myError];

      news = [NSArray arrayWithObjects:[res allKeys], [res allValues], nil];

      NSLog(@"%@", news);

    //[mainTableView reloadData];
}

Then I want to insert all the JSON data into an array, so I can display the data in my tableview.

My tableview code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MainCell"];

    if(cell == nil){
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MainCell"];
    }

    cell.textLabel.text = [[news objectAtIndex:indexPath.row] objectForKey:@"Name"];
    cell.detailTextLabel.text = [[news objectAtIndex:indexPath.row] objectForKey:@"Adress"];

    return cell;
}

But my app crashes with the error:

-[__NSArrayI objectForKey:]: unrecognized selector sent to instance. 

How can I insert the JSON object into an NSArray, so I can display it in my tableview?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T06:29:07+00:00Added an answer on June 16, 2026 at 6:29 am

    I found a simple solution myself, that fits my project better:

    I just did the following:

        NSDictionary *res = [NSJSONSerialization JSONObjectWithData:data options:0 error:&myError];
    
    NSArray news = [NSArray arrayWithObject:res];
    

    and with that I am able to use the following code to display the JSON contents in my tableview.

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MainCell"];
    
        if(cell == nil){
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MainCell"];
        }
    
    
        cell.textLabel.text = [[news objectAtIndex:indexPath.row] valueForKey:@"name"];
    
        cell.detailTextLabel.text = [[news objectAtIndex:indexPath.row] objectForKey:@"Location"];
    
        return cell;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following scenario: I am parsing a JSON Response from a server
I have the following string from a REST JSON response: [ { uid:10512213, name:Bob
I have the following json response from server: $data=[[ {left:{p1:{x:0,y:0},p2:{x:0,y:15}}, right:{p1:{x:15,y:0},p2:{x:15,y:15}}, up:{p1:{x:0,y:0},p2:{x:15,y:0}}, bottom:{p1:{x:0,y:15},p2:{x:15,y:15}}}, {left:{p1:{x:0,y:15},p2:{x:0,y:30}},
Say I have the following JSON string returned from server: { response:{ imageInstances:{ one:{
I have the following JSON string (from wikipedia http://en.wikipedia.org/wiki/JSON ) { name:Product, properties: {
I have following array return from server side: [json] => Array ( [0] =>
I have to following response from a server: page:{result:ok,id_photo:36782710} .And I'm trying to obtain
I have the following JSON object: { response: { status: 200 }, messages: [
In my servlet I have the following code: response.setContentType(application/json);//set json content type PrintWriter out
I have the following JSON String { name:Product, properties: { id: { type:number, description:Product

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.