I have a small application running out of a single class. It's not ideal, but I'm still learning. In the header of my class I have a NSMutableArray defined, that I manipulate in the .m file.
I have connected the open menu of my nib to an IBAction, that brings up an openPanel, with the selector defined as another method in my class. In that method I use the following call;
The strange thing is that I can have any number of objects in the array, but when I put in a break point on this line it says that there are 0 objects. This is before the line is run. After the line is executed it still say 0 as you would expect. However when the application continues elsewhere, all the objects are back in the array.
The only thing I can think of is that the compiler is treating this instance of myArray as something different to the rest of the class, hence my question about scope.
To test this out I tried setting a BOOL flag and calling the removeAllObjects elsewhere in the code, based on it, but the same thing happens with the flag. I set it in the selector method but it is different to the instance in the rest of the class.
Can anyone explain this behaviour to me? Is this because I'm not using a MVC architecture?
I have connected the open menu of my nib to an IBAction, that brings up an openPanel, with the selector defined as another method in my class. In that method I use the following call;
Code:
[myArray removeAllObjects];
The strange thing is that I can have any number of objects in the array, but when I put in a break point on this line it says that there are 0 objects. This is before the line is run. After the line is executed it still say 0 as you would expect. However when the application continues elsewhere, all the objects are back in the array.
The only thing I can think of is that the compiler is treating this instance of myArray as something different to the rest of the class, hence my question about scope.
To test this out I tried setting a BOOL flag and calling the removeAllObjects elsewhere in the code, based on it, but the same thing happens with the flag. I set it in the selector method but it is different to the instance in the rest of the class.
Can anyone explain this behaviour to me? Is this because I'm not using a MVC architecture?