1

我已将数据从 json 提取到数组中,但是当我访问数组内容时,它不显示它显示在两条记录中,但不显示内容

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);
}

我想访问,

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

当 NSLog 时它在 cellText 中没有显示任何内容,我不知道为什么会这样,因为数组有内容。

   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;
   }
    )
4

1 回答 1

2

您正在使用

"survery_Description"

在您的代码中,但是 JSON 只有

"survey_description"

(注意非大写)

于 2012-07-26T10:46:12.813 回答