Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iOS中使用objective-c将JSON转换为Object_Ios_Objective C_Json_Object_Jsonmodel - Fatal编程技术网

在iOS中使用objective-c将JSON转换为Object

在iOS中使用objective-c将JSON转换为Object,ios,objective-c,json,object,jsonmodel,Ios,Objective C,Json,Object,Jsonmodel,我有反对意见 @interface Hourly (CoreDataProperties) @property (nullable, nonatomic, retain) NSDate *dt; @property (nullable, nonatomic, retain) NSNumber *temp; @property (nullable, nonatomic, retain) NSNumber *temp_min; @property (nullable, nonatomic, ret

我有反对意见

@interface Hourly (CoreDataProperties)

@property (nullable, nonatomic, retain) NSDate *dt;
@property (nullable, nonatomic, retain) NSNumber *temp;
@property (nullable, nonatomic, retain) NSNumber *temp_min;
@property (nullable, nonatomic, retain) NSNumber *temp_max;
@property (nullable, nonatomic, retain) NSNumber *humidity;
@property (nullable, nonatomic, retain) NSNumber *pressure;
@property (nullable, nonatomic, retain) NSString *main;
@property (nullable, nonatomic, retain) NSString *des;
@property (nullable, nonatomic, retain) NSString *icon;

@end
和url

http://api.openweathermap.org/data/2.5/forecast/dayly?lat=35&lon=139&cnt=2
我无法通过jsonmodel pod将json添加到对象中,因为列表中的天气是一个数组。

@Ngọc.塔伊: 我不太明白你的问题。但是,如果您想将JSON(包含对象数组)解析为对象

很简单,您可以尝试:

希望这有帮助

试试我的项目。它可以帮助您轻松地将json字符串转换为NSArray:

NSArray *dataArray = [BWJSONMatcher matchJSON:YOURJSONSTRING withClass:[Hourly class]];

该库是完全开源的,并获得麻省理工学院的许可。

阅读pod文档,了解如何将其与阵列或使用
NSJSONSerialization
,我不明白你的问题是什么。显然,如果你使用一个库,特别是一个刚刚开始到处乱发垃圾邮件的库,您完全有责任检查源代码,并确保它确实符合您的要求。没有别的。一个以字符串作为参数而不是NSData的JSON处理器是非常可疑的。这个库是完全开源的,并且在MIT许可下。