gpt4 book ai didi

ios - NSMutableArray addObjects 崩溃

转载 作者:行者123 更新时间:2023-11-29 12:45:59 26 4
gpt4 key购买 nike

<分区>

我正在向我的 NSMutableArray 添加数组,但它崩溃了。这是我的代码:

 NSURL *url = [NSURL URLWithString:jsonUrl];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if (data.length >0 && connectionError ==nil) {
NSDictionary *myData = [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL];


self.currWeather = [[NSMutableArray alloc] init];
self.weatherIconUrl =[[NSMutableArray alloc] init];

self.currWeather = myData[@"data"][@"current_condition"][0][@"weatherIconUrl"];
self.weather = [[myData objectForKey:@"data"] objectForKey:@"weather"];


self.weatherIconUrl = [self.weather valueForKeyPath:@"weatherIconUrl"];

[self.weatherIconUrl addObjectsFromArray:self.currWeather]; //here is the problem
NSLog(@"the url is %@",self.weatherIconUrl);
}
}];

我试图将“currWeather”从 NSMutable 更改为 NSArray 但它又失败了。

这里是错误:

-[__NSArrayI addObjectsFromArray:]: unrecognized selector sent to instance 0x908e3a0
2014-05-15 16:21:58.376 myRestSample[2239:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI addObjectsFromArray:]: unrecognized selector sent to instance 0x908e3a0'

谁知道为什么?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com