我一直在嘗試使用JSONmodel嘗試從我的服務器獲取數據到我的ios設備。我已經正確地建立了我的類,但由於某種原因,它在調用url之後會一直返回null。使用JSONmodel嘗試從服務器獲取數據到ios設備
feed = [[Feeds alloc] initFromURLWithString:@"http://http://www.cs4768project.net76.net/untitled.php?action=getShops"
completion:^(JSONModel *model, JSONModelError *err) {
NSLog(@"reached");
//json fetched
NSLog(@"shops: %@", feed.shops);
這裏是保存飼料
@interface Feeds : JSONModel
@property(strong,nonatomic) NSArray* shops;
@end
與我的咖啡館類沿模型
@interface CoffeeShop : JSONModel
@property(strong, nonatomic) NSString* name;
@property(nonatomic) CLLocationDegrees latitude;
@property(nonatomic) CLLocationDegrees longtitude;
@end
的JSON輸出:
{"name":"Starbs","latitude":"45","longtitude":"-52"}
我一直試圖找出一段時間的解決方案並沒有拿出任何東西,我很難爲什麼這不工作。任何幫助都是極好的。
難道是因爲URL中有2個'http://'嗎? – 2013-03-27 00:04:11
請顯示JSON文件的一部分和JSON解碼代碼。 – Alex 2013-03-27 00:08:35
@ChrisLoonam只是注意到,並刪除它,它仍然無法正常工作。當我檢查錯誤消息錯誤時會出現此錯誤操作無法完成。 (可可錯誤3840.) – user1179321 2013-03-27 00:10:16