iphone - NSMutableArray count keeps changing -


I have a lot of code, which I need to quote here, but in my app representative I have NSMutableArray. Then in the second category, it creates a new entry on NSMutableArray, but when returning to another class, it should be used to display something on the screen, it does not show anything by putting NSog at the end of the class of NSMutableArray It's number 1 display Injury, and then the same Anselog by entering a code at the beginning of the class, which is to use it returns 0.

Any idea why this is?

Edit: OK, I will try and include all the related codes.

App representative. H:

  @ interface bars AppDiget : NSObject & lt; UIApplicationDelegate & gt; {NSMutableArray * colourPalettesContainer; } @ Property (assign, readwrite) NSMutableArray * colourPalettesContainer; @end   

App delegate.m:

  #import "palettesAppDelegate.h" @ Implementation Pappets AppDelegate @ synthesis colourPalettesContainer; - (Zero) Delok [[Colorpellettent release]; [Super DeLoc]; } @end   

Homeview:

  #import & lt; UIKit / UIKit.h & gt; # Import "Handling Pallets" @ Interface Homeview: UIViewController {Handling Polllets * Handling Pallets; } @end   

Homeview.m: #import "HomeView.h" #import & lt; Quartzcore / quartz coir H & gt; @ Implementation Home V - (zero) viewDidoadload {[Super Viewedload]; Handling Pallets = [[Handling Pallets Elok] Init]; [Handlingpletts newplet]; } - (Zero) VisualElementsPower: (BOOL) Animated {@ "View will appear:% i", [Datacenter.Com Corporate Counter]]; Int NumberFaxxing = [Datacenter.Com Corporate Counter];} - (Zero) Deloc { [HandlingPaletts release]; [Super deLock];} @end

HandlingPalats.H:

  #import & lt; UIKit / UIKit.h & gt; ; @ Interface Handling Pallets: UIViewController {} - (zero) Newpetlet; @end   

HandlingPalats.M:

  #import "HandlingPollett." #import " HomeView.h "#import" palettesAppD Elegate.h "@implementation handling pallets - (empty) newplaylet {palletsapply * datacenter = (bandage appidlegate *) [[UIApplication shared epicling]]; // If this is the first palette then (datacenter.colourPalettesContainer == zero) {dataCenter. ColourpalettesContainer = [[NSMutableArray alloc] init];} // Add a new palette [dataCenter.colourPalettesContainer addObject: @ "test1", @ "test2", zero]; NSLog (@ "handling:% i", [datacenter Corporate counters]);} - (zero) delok [[super delok]; } @end    

Your main muteover is in your app representative. So, see what happens, if you want access to the array in each method, then you have the line to establish an app representative relationship.

  Stripes AppDigital * DataCenter = (Pelletsappidileget *) [ UIApplication sharedApplication] representative];   

Now, when you call the Data Center object, you will refer to App Deliate and your program will get an array.

You may also know that you should have a #import "palettesAppDelegate.h" in every object, in reference to the application representative.

Note that adding an app representative code is not necessarily a proper way to deal with the architectural approach. But if it works for you then at least know the answer to your original question.

Comments