[英]why my array is null in second time, when I assigned it's first object to dictionay in objective C, ios
Occured a crazy situation. 发生了疯狂的情况。 I assinged values to a mutable array in my first method.it worked properly.this is the my code for it.
我在第一个方法中将值赋给了一个可变数组,它工作正常,这是我的代码。
for (NSDictionary *final in SectorsArray)
{
MoreFligh *more = [MoreFligh new];
more.flightnumber = [final objectForKey:@"FLI_NUM"];
more.airlinecode = [final objectForKey:@"ARL_COD"];
more.departureairport = [final objectForKey:@"DepatureAirport"];
more.departureday = [final objectForKey:@"DepatureDay"];
more.departuredate = [final objectForKey:@"DepatureDate"];
more.departuredime = [final objectForKey:@"DepatureTime"];
more.arrivalairport = [final objectForKey:@"ArrivalAirport"];
more.arrivalday = [final objectForKey:@"ArrivalDay"];
more.arrivaldate = [final objectForKey:@"ArrivalDate"];
more.arrivaltime = [final objectForKey:@"ArrivalTime"];
[testingArray addObject:more];
}
this time testing array is not null and there are two objects with values.no problem. 这次测试数组不为null,并且有两个带有value的对象。没问题。
then in my second method I chencked that array like this. 然后在第二种方法中,我像这样修改数组。
- (void)chk
{
id bbbbb = testingArray.firstObject;
NSLog(@"%@",bbbbb);
}
then it int the bbbbb
(I used a breakpoint here) it had two objects with values.then I check with following code. 然后它在
bbbbb
(我在这里使用了一个断点)里面有两个带有值的对象。然后我用下面的代码进行检查。
- (void)chk
{
NSDictionary *bbbbb = testingArray.firstObject;
NSLog(@"%@",bbbbb);
}
at this time it shows testing array has to objects but with no values. 这时它显示测试数组必须对象,但没有值。 then I have to create a new model class assign value.otherwise after this step it shows only like no value.I have attached some pictures.if anyone wants I can provide any other details.
然后我必须创建一个新的模型类赋值。否则在此步骤之后它仅显示为无值。我已经附上了一些图片。如果有人希望我可以提供任何其他详细信息。
] 2 [
] 2 [
] 3
] 3
when I create a new model, then it works properly until I checked like above. 当我创建一个新模型时,它可以正常工作,直到我如上所述进行检查为止。
- (void)chk
{
MoreFligh *bbbbb =(MoreFligh *) testingArray.firstObject;
NSLog(@"%@",bbbbb);
}
I do not understand what the testingArray is, instance variable or temporary variable? 我不知道什么是testingArray,实例变量还是临时变量?
If the instance variable that is, take a look at assignment, make sure no place makes testingArray nil or removeAllObjects. 如果是实例变量,请看一下赋值,确保没有地方使testingArray为nil或removeAllObjects。
Or show the .m file completely, let us check. 或完整显示.m文件,让我们检查一下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.