我是新來的ios和它的發展。我有乾淨的代碼設置正確AFNetworking
。我的基地URl的json Encording有JSON對象和數組以及值。在我的JSON輸出中,我希望獲得「縮略圖」的值,每次我都會得到Null。請幫助我獲取我的json輸出的「名稱,縮略圖,ID,圖像」。請找到我的NSDictionary類型的打印對象的NSlog。AFNetworking GET json值並保存NSMutablearray
2014-07-20 09:08:33.110 WADTourisum[1157:60b] Reachability Flag Status: -R ------- networkStatusForFlags
2014-07-20 09:08:33.879 WADTourisum[1157:60b] JSON: {
Main = (
{
id = 1;
"image_bundle_id" = 1;
images = (
"http://wearedesigners.net/clients/clients12/tourism/images/guides/oceans/slide_images/1.jpg",
"http://wearedesigners.net/clients/clients12/tourism/images/guides/oceans/slide_images/2.jpg",
"http://wearedesigners.net/clients/clients12/tourism/images/guides/oceans/slide_images/3.jpg"
);
name = OCEAN;
thumbnail = "http://wearedesigners.net/clients/clients12/tourism/images/guides/thumbs/ocean.jpg";
},
{
id = 2;
"image_bundle_id" = 23;
images = (
"http://wearedesigners.net/clients/clients12/tourism/images/guides/heritages/slide_images/1.jpg",
"http://wearedesigners.net/clients/clients12/tourism/images/guides/heritages/slide_images/2.jpg",
"http://wearedesigners.net/clients/clients12/tourism/images/guides/heritages/slide_images/3.png"
);
name = Heritage;
thumbnail = "http://wearedesigners.net/clients/clients12/tourism/images/guides/thumbs/heritage.jpg";
},
{
id = 3;
"image_bundle_id" = 0;
images = (
);
name = "Tea Country";
thumbnail = "http://wearedesigners.net/clients/clients12/tourism/images/guides/thumbs/teaCountry.jpg";
},
{
id = 4;
"image_bundle_id" = 0;
images = (
);
name = "WILD LIFE";
thumbnail = "http://wearedesigners.net/clients/clients12/tourism/images/guides/thumbs/wildLife.jpg";
},
{
id = 5;
"image_bundle_id" = 0;
images = (
);
name = Culture;
thumbnail = "http://wearedesigners.net/clients/clients12/tourism/images/guides/thumbs/culture.jpg";
},
{
id = 6;
"image_bundle_id" = 0;
images = (
);
name = "NIGHT LIFE";
thumbnail = "http://wearedesigners.net/clients/clients12/tourism/images/guides/thumbs/nightLife.jpg";
}
);
}
我的代碼片段
-(void) retriveData
{
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"http://www.fr20.wearedesigners.net/WADMac/tourism/fetchGuideListAndroid.php"
parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.posts =(NSDictionary *)responseObject;
self.post =self.posts[@"thumbnail"];
NSLog(@"JSON: %@", self.post);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Please log into internetet"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
}];
}
您是否還可以包含以下結果的代碼:'每次我獲得空值時都會獲取「縮略圖」的值# – dezinezync
@dezinezync 2014-07-20 18:56:08.062 WADTourisum [1551 :60b]可達性標誌狀態:-R ------- networkStatusForFlags 2014-07-20 18:56:08.848 WADTourisum [1551:60b] JSON:(null) –
我猜prop'post'是一個'NSArray'? – dezinezync