I need to keep track of some image views which can be dragged around the screen and located within other images views. For example footballs in goals. I’d like to do this by having some extra properties attached to the footballs, current goal and times seen in the goal.
@property (nonatomic, retain) IBOutlet IBOutletCollection(UIImageView)
NSArray *multipleFootballs;
I figure, that I have to create a super class.
Although I’m not sure the best way to do this ?
EDIT3 : Thanks nick, but how do I then access a instance property ?
@interface FootballImageView : UIImageView {
int intCurrentGoal;
}
@property (readwrite) int intCurrentGoal;
@implementation FootballImageView
@synthesize intCurrentGoal;
-(id)init {
self = [super init];
if(self) {
// do your initialization here...
}
return self;
}
@end
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
for (id football in multipleFootballs) {
//if ([[touches anyObject] intCurrentGoal] == 0) {
//if (football.intCurrentGoal == 0) {
Should be easy:
IBOutletCollection(UIImageView)toIBOutletCollection(MyImageView)–
Reply for edit 3
The problem you are facing is the anonymous type (id) you are using in touchesBegan. Put in a check like this: