数据未显示在数组中

时间:2012-07-26 09:07:42

标签: iphone xcode arrays

我已经从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;
   }
    )

1 个答案:

答案 0 :(得分:2)

您正在使用

"survery_Description"

在您的代码中,但JSON只有

"survey_description"

(注意非大写)