Using global variables in Objective-C

后端 未结 6 855
一个人的身影
一个人的身影 2020-12-07 19:33

First of all, I tried almost all the solutions given in stackoverflow but I didn\'t succeed in implement global vars, I even did a step by step tutorial and still I get the

6条回答
  •  抹茶落季
    2020-12-07 20:06

    The error has nothing to do with global variables. The error message

    -[__NSArrayM length]: unrecognized selector sent to instance 0x8b7fbc0
    

    indicates that you somewhere in your code assigned a NSMutableArray to farmerCardNumber instead of a NSString.

    For example, if you do something like

    farmerCardNumber = [someDictionary objectForKey:@"someKey"];
    

    and [someDictionary objectForKey:@"someKey"] happens to be an array and not a string, then farmerCardNumber points to that array, even if it was declared as pointer to a string.

提交回复
热议问题