Ok, so this has been driving me mad for a while, but it occasionally self corrects so I’ve dealt with it, but it’s time to fix it!
Situation is as follows:
View created in Interface Builder for iOS. Contains a UIButton referenced as ‘banana015’
Method in my implementation .m as follows:
- (IBAction)draggedOut: (id)sender withEvent: (UIEvent *) event {
if ([[NSUserDefaults standardUserDefaults] integerForKey:@"edittingmode"] == 3) {
UIButton *selected = (UIButton *)sender;
selected.center = [[[event allTouches] anyObject] locationInView:self.view];
if ([[NSUserDefaults standardUserDefaults] integerForKey:@"changeskin"] == 1) {
[self scifiTempSave];
}
else if ([[NSUserDefaults standardUserDefaults] integerForKey:@"changeskin"] == 2) {
[self bananaTempSave];
}
else if ([[NSUserDefaults standardUserDefaults] integerForKey:@"changeskin"] == 3) {
[self orangeTempSave];
}
}
else{}
}
And declared in my .h Header as
-(IBAction)draggedOut:(id)sender;
Now, when I connect the button to the ‘draggedOut:’ method in Interface Builder using the Touch Drag Inside event, I can drag the button around when I build and run the project (expected behaviour) however when I release the app crashes.
In the past I’ve been able to connect to a method that appears as “draggedout: withevent” which works beautifully. This evening I’ve connected some 50 items up to this ‘draggedout: withevent’ option and it works beautifully for each one – I have however got two UIButtons (identical in almost every way (different referencing outlets) that I have yet to connect to it, and I’ll be damned if it’ll let me.
Can anyone help? This has been infuriating for some time. The option disappears, yet all those that I previously connected to it still work perfectly, I just can’t hook anything new up to it…or the old ones if I disconnect them.
The one problem I can see is that your method declaration in the header is not the same as your implementation. The header declaration should be the first line of the method in the implementation plus a semicolon:
To get more info on the crash, you should try setting NSZombieEnabled to true.
To answer your question in the comment, I don’t know why you would get the option of a
draggedout:method in addition to the one includingwithEventif it’s not declared in your code.