objective c - Trying to pass NSMutableArray from singleton -


I have collected a permanent data named as a singleton, which is the code DataHolder I want to store all the highscore from each level in an array, and then there should be access to that array in another class. Whatever I tried to do, I put it in the code below. When I log the value of the array, it seems that randomly log any of its properties, for example CCColor: 0x175bf270 if I ever try to do something similar for it , Or some of its values ​​are contained in the array, the next time I run it, before I go back to the log, just say Bad Access (code = 1), address 0x10 . How to avoid this when doing the same thing any suggestions? Thanks!

DataHolder.h

  #import & lt; Foundation / Foundation.h & gt; @interface DataHolder: NSObject + (DataHolder *) sharedInstance; @property (nonatomic, allocated) NSMutableArray * levelHighscoresArray; @end  

DataHolder meter

  @implementation DataHolder - (id) init {auto = [super init]; If (self) {self.levelHighscoresArray = [NSMutableArray arrayWithObjects: [NSNumber numberWithInt: 10], zero]; NSLog (@ "Maximum Score Array Level 1% @", _levelHighscoresArray [0]); // works fine} return self;} + (DataHolder *) sharedInstance {static DataHolder * _sharedInstance = nil; Fixed dispatch_o Nce_t security once; Despatch_postima (& amp; one time, acuiterproject, ^ {_sharedInstance = [[self-restraint] init];)); To return; }  

OtherClassImAccessingArrayFrom.m

  - (zero) viewDidLoad {[super viewDidLoad]; NSLog (@ "Temfigoscors1% @", [[Dealhilder Shared Instance] Level Highcrosserre]); // Returns an error thread above 1: EXC_BAD_ACCESS (code = 1, address = 0x10)}  

It feels good to leave this part.

  @ Property (non-monetized, assign) NSMutableArray * levelHighscoresArray;  

I will change it on

  @property (nonatomic, strong) NSMutableArray * levelHighscoresArray;  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -