Using global variables in Objective-C

后端 未结 6 859
一个人的身影
一个人的身影 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:10

    Why donot you try something like:

    #import "GlobalVars.h"
    
    NSArray *farmerlist;
    NSArray *truckBoxes;
    NSString *farmerCardNumber = nil;
    NSString *fName = nil;
    @implementation GlobalVars
    {
    
    }
    @end
    

    or

    #import "GlobalVars.h"
    
    NSArray *farmerlist;
    NSArray *truckBoxes;
    NSString *farmerCardNumber = @"";
    NSString *fName = @"";
    @implementation GlobalVars
    {
    
    }
    @end
    

    AND it seems like you have passed mutable array to your string varibale, that is why you are getting that error.

提交回复
热议问题