NSArray of int[]

后端 未结 4 1725
悲哀的现实
悲哀的现实 2020-12-15 12:23

I am needing to store a heap of int[] for my levels.

I decided that storing the int[]\'s in an NSMutableArray and getting a random one from the array would be a good

4条回答
  •  鱼传尺愫
    2020-12-15 12:40

    Use NSNumber to store int in an NSMutableArray.

    Here's sample code :

    // Add 
    [yourMutableArray addObject:[NSNumber numberWithInt:yourInt]];
    
    // Get 
    yourInt = [((NSNumber*)[yourMutableArray objectAtIndex:0]) intValue];
    

提交回复
热议问题