简体   繁体   English

为什么我的数组第二次为空,当我将它的第一个对象分配给目标C中的字典时,ios

[英]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. 然后我必须创建一个新的模型类赋值。否则在此步骤之后它仅显示为无值。我已经附上了一些图片。如果有人希望我可以提供任何其他详细信息。 这是我核对字典[![] [1] ] 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.

相关问题 在我的Objective-C代码中间接调用时,为什么这个C数组为NULL? (cocos2d的) - Why is this C array NULL when indirectly called in my Objective-C code? (cocos2d) 当我尝试从另一个视图控制器(Objective-c?)访问变量时,为什么变量为null? - Why is my variable null when I am attempting to access it from another view controller (Objective-c? 在iOS的Objective C中异步发送请求时,为什么我的数据被破坏? - Why is my data getting corrupted when I send requests asynchronously in objective c for iOS? 目标C整数第一次是0,但是第二次改变 - Objective C Integer is 0 first time, but it changes second time iOS:选择选项第一次返回空值,而不是第二次返回 - iOS: selecting option returns null first time, not second time 第一次打开ios模拟器时,它要求输入密码 - When I First time open my ios Simulator, It ask for password Objective C iOS - objc_object :: sidetable_retain / release占用循环中的CPU时间? - Objective C iOS - objc_object::sidetable_retain/release chewing up CPU time in my loop? 如何在目标c中连接两个可变数组,例如第一个数组的一个元素和第二个数组的第一个元素 - How to concatenate two mutable array like one element of first array and first element of second array in objective c iOS:检查首次使用Facebook登录的用户-目标C - iOS: Check first time user logs in using Facebook - Objective C ios / objective-c:在将Null插入核心数据时如何防止异常? - ios/objective-c: How can I prevent exception when inserting Null into core data?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM