views:

31

answers:

1

I have a table view that gets refreshed two different ways. Both are through a button, and as a matter of fact, both are through the same IBAction in the same class!

Here's my problem:

The buttons are in two different .xib files, the button in the same xib as the table view works perfectly, while the one in the different xib does the method to get the new data, but it DOES NOT refresh the table. Same exact method, different results. To get the IBAction for the other button I simply dragged out an NSObject in IB and set its class to the class of my table view, which contains the IBAction, then hooked it up to my button.

How can I fix this?

+1  A: 

Sounds like you're creating a second, parallel, object of your class in the second XIB. The button sends a message to that instance, which does some of the stuff you expect because it's an object of the right class, but it isn't actually the right object and isn't connected to your view.

What you need to do is ensure that both buttons talk to the same instance. This is easiest if the target is in the responder chain -- you should be able to set the button's target to First Responder and the message will find its way to the right place. Otherwise, you need to get a pointer to the target into the XIB, eg as an IBOutlet in the object that will be File's Owner.

walkytalky
It's also possible that the object that receives this action message should be the owner of the second nib, if not both of them.
Peter Hosey