开发者

Global Mutable array

开发者 https://www.devze.com 2023-01-29 06:34 出处:网络
I wish to be able to access this array in any sub in my secondviewcontroller, were do i add this coding to make it accessible via every sub

I wish to be able to access this array in any sub in my secondviewcontroller, were do i add this coding to make it accessible via every sub

    NSMutableArray *YoutubeArray;
   开发者_如何学运维 YoutubeArray = [[NSMutableArray alloc] init];


Create a property in the interface.

interface (.h file):

NSMutableArray *_youtubeArray;

@property(nonatomic,retain)NSMutableArray *  youtubeArray;

implementation (.m file):

@synthesize youtubeArray=_youtubeArray;


//in viewDidLoad/initwith...
self.youtubeArray = [[NSMutableArray alloc] init];

Alternatively, and for more scope Use a singleton structure

0

精彩评论

暂无评论...
验证码 换一张
取 消