views:

56

answers:

2

Hi guys,

in my iphone app one event (touch up inside UIButton) is connected to three actions in different classes. The first action creates a game object, the second pushes the a new view controller and the third triggers an method in the pushed view controller.

On interface builder I wired these actions to the event in the order mentioned above but the app crashes sometimes when I press the button.

Does some body know if the order in which I wired the action on IB will be maintained at runtime in my device and others?

A: 

maybe this will help?

http://stackoverflow.com/questions/632309/iphone-sdk-ibaction

jmont
+1  A: 

I'd guess that the order in which actions are called is not guaranteed to be the same order in which you wire them up in IB. Consequently, your app might be trying to configure the view controller before it creates it. You can verify the calling order by putting an NSLog statement in each of your action methods.

Even if the actions are called in IB order, that's a code maintenance nightmare; imagine coming back later to insert a new action in your UIButton and needing to remember the order in which you originally wired them up.

Solution: To enforce order, create a single IBAction method that calls the other three methods in the desired order.

James Huddleston
Thank you James, you are right, the best thing to do is the single IBAction.
cwagner72