The events array is defined and synthesized and I've tested it and at that point it has been passed in correctly and exists.
If I try to reference it from drawRect it is just an empty array. Can you not reference things from drawRect? I originally tried to build the array from the drawRect, but it also threw an error trying to access the managed object context.
I see you're not retaining the array you get - is it possible that the original array is autoreleased, or gets released or otherwise emptied by code in the original caller?
If you NSLog(@"%@:", eventsArray) in that init method, is the eventsArray ok there?
I see you're not retaining the array you get - is it possible that the original array is autoreleased, or gets released or otherwise emptied by code in the original caller?
If you NSLog(@"%@:", eventsArray) in that init method, is the eventsArray ok there?
I tried adding retain to the eventsArray and the eventsArray in the caller and it didn't change.
I am using NSLog to check and yes it is the correct information in the init method.
If it's not a retain issue, you could try logging the *address* of the array in the init and again in the drawRect.
NSLog(@"%d", eventsArray)
If the address changes, then someone is changing the value of eventsArray somewhere. If the address does not change but the contents do, then someone else has a pointer to the array you're passing in is removing the contents.
If it's not a retain issue, you could try logging the *address* of the array in the init and again in the drawRect.
NSLog(@"%d", eventsArray)
If the address changes, then someone is changing the value of eventsArray somewhere. If the address does not change but the contents do, then someone else has a pointer to the array you're passing in is removing the contents.
The address is normal in init and is 0 in drawRect. I think I'm going to do it differently and create the array in init rather than passing it in.
The address is normal in init and is 0 in drawRect. I think I'm going to do it differently and create the array in init rather than passing it in.
Strange - if the address changes to 0, then either someone is doing eventsArray=nil or you're dealing with a different object. You could try logging the address of "self" to see if it's the same object.
Could also be a buffer overrun somewhere, but that's much less likely.