I created an array of ImageViews in a Buttonclicked method:
UIImageView *arrayOfImageViews[10]
I successfully loaded them on the screen using a loop. (Big accomplishment for this beginner!)
But I want to refer to them in other methods (e.g. touchMove).
Where do I declare arrayOfImageViews to be both an array and a class of UIImageView so that I can use them in other methods? From what I can find, I’m to declare them in the .h and above Implementation in the .m. But I can’t figure out the code and location to define the object as an array of UIImageViews in anything but the original function.
Try using a property. So in the
.hfile, you want to define the property something like this:Now in the implementation (
.mfile) You need to bind this property like thisThat should do it… Sorry I didn’t have time to post code that actually compiles but it should help. Basically now you have a property on the class and you can access it like
self.arrayOfImages, or even justarrayOfImages(from withinMyClass). Also, I usedNSArraywhich I suggest you do too. However you can also useUIImageView* arrayOfImagesif you prefer.