Can i have a single NSMutableArray in my multiple views application?

前端 未结 4 1165
小鲜肉
小鲜肉 2020-12-22 09:05

I have a navigational based application which has multiple views. Is it possible to use one single NSMutableArray for the whole applicaiton? Can i add objects to that NSMuta

4条回答
  •  暖寄归人
    2020-12-22 09:13

    On the Singleton approach add this

    instance.arrGlobal = [[NSMutableArray alloc] init];
    

    this way:

    @synchronized(self)    
    {    
        if(instance==nil)    
        {    
    
            instance= [DataClass new];
            instance.arrGlobal = [[NSMutableArray alloc] init];
        }    
    }    
    return instance;
    

    This way you can initilize the array and use it properly.

提交回复
热议问题