user1553768
user1553768

Reputation: 35

Data not showing from array

I have fetched data from json into array but when i access array contents it does not show it shows in count two records but do not show the contents

for (int i = 0; i<[tempArray count]; i++)
{
   id *item = [tempArray objectAtIndex:i];
   NSDictionary *dict = (NSDictionary *) item;
   ObjectData *theObject =[[ObjectData alloc] init];
   [theObject setUser_id:[dict objectForKey:@"user_id"]];
   [theObject setSurvey_id:[dict objectForKey:@"survey_id"]];
   [theObject setSurvey_title:[dict objectForKey:@"survey_Title"]];
   [theObject setSurvey_Description:[dict objectForKey:@"survey_Description"]]; 
   [theObject setDate_Created:[dict objectForKey:@"date_Created"]];

   NSString*testing=[dict objectForKey:@"survey_id"];
   NSLog(testing);

   [surveyList addObject:theObject];
   [theObject release];
   theObject=nil;

   int count =[surveyList count];
   NSLog(@"Total is %d",count);
}

I want to access like,

ObjectData*data=[surveyList objectAtIndex.path.row];
NSString*cellText=data.surveyDescription;

It does not show anything in cellText when NSLog, I don't know why it is like that because array has contents.

   tempArray: (
    {
    color = "[UIColor GrayColor]";
    "date_created" = "2012-07-24 22:39:14";
    "survey_description" = "Survey To get feedback from clients about food quality and any suggestion to improve the service";
    "survey_id" = 1;
    "survey_title" = "Resturant Survey";
    "user_id" = ali40;
    },
    {
    color = "[UIColor greyColor]";
    "date_created" = "2012-07-25 00:43:42";
    "survey_description" = "Toursim Survey";
    "survey_id" = 2;
    "survey_title" = "Travel Servey";
    "user_id" = ali40;
   }
    )

Upvotes: 1

Views: 78

Answers (1)

Amit Shah
Amit Shah

Reputation: 4164

You are using

"survery_Description"

in your code, however the JSON only has

"survey_description"

(Note the non capitalisation)

Upvotes: 2

Related Questions