0

Is the app delegate the only place to put action methods for controls? Can other user created objects be targets as well? So if I click a button and I want an object I created to respond, where would I create the object and how would I assign it to the control? I am using Xcode 4.2. Is it even possible to do this (user created object respond to a button for instance)?

Thanks in advance

rubixibuc
  • 7,111
  • 18
  • 59
  • 98

1 Answers1

0

You need to use addTarget in code or use nib editor to drag the proper actions to the proper IBOutlets thats a lot harder to explain so you might need a reference on the editor.

 [button addTarget:instanceOfObject selector:@selector(methodToCall:) forControlEvents:UIControlEventTouchUpInside];
caguilar187
  • 753
  • 3
  • 10
  • But I would basically have to write that code within the appdidfinishlaunching method, as well as create the object there? What's an IBOutlet? Is there any way to do this with just the interface editor, without editing the code for the controls themselves? Thanks :-) – rubixibuc Nov 12 '11 at 08:29
  • every view in the app should have either a UIViewController or UIView. if the .h is a UIViewController then you can use the viewDidLoad to get access to the view and add targets to things there. UIView you can use the initWithFrame call to do the same thing. – caguilar187 Nov 12 '11 at 08:39