Wednesday, 21 August 2013

Items disappearing from array within array

Items disappearing from array within array

I create a NSMutableArray that I need as long as my app lives, lets call
it suseranArray, just after the @implementation of my main class. This
Array will hold several objects of a class called Vassal. A Vassal is
simply:
1) A NSMutableString 2) Another NSMutableString 3) A NSMutableArray 4)
Another NSMutable Array
Each Vassal created is also needed for the life of the app, and they never
change.
These objects are made as (retain) properties in an .h file, synthesized
in the .m file, and each given an alloc+init whenever the object Vassal is
created during the init function. Each vassal has data filled in and
stored in the suzerain Array. the 3rd item always has several elements,
and after a bug appeared, I put a line to check if it is ever empty, but
it never is, and life is good.
Now, later on when a certain Vassal object is needed, we try to access its
3rd property to fetch the data in there, and sometimes that array empty...
I checked to see if it disappeared somehow, but it is always there on the
debug, carrying a nice address like 0x2319f8a0 which makes sense since the
NSMutableString just above it is at address 0x2319fb40 - (I was expecting
00000000 after a lot of headache). What is happening? I my head, I am
creating an RETAINed objects, which retains data put in by default, and
that object is put inside another, but somehow the data inside the array
vanishes. What possible scenario could lead to this? Thank you for your
time :)
Note: the last array currently just holds one item at this stage of
development, and curiously enough, that one item is never missing, despite
the two arrays being 'brothers'

No comments:

Post a Comment