I would make the table view controller a delegate of the details view controller. Then do something like this in the details view controller:
-(IBAction) nextButtonClicked:(id)inSender {
NSDictionary *data = [delegate detailView:self nextDetailsForCurrent:myDetails];
if ( data ) [self setDetails:data];
}
You could make a much more robust delegate protocol than this oversimplified method, but hopefully this will get you started.
Edit:
There is nothing inherently special about a delegate. It is just one object that makes decisions on behalf of another object. In Objective-C a delegate is usually defined as a protocol, although it used to just be a category of NSObject.
Create a delegate protocol like this:
@protocol DetailDelegate <NSObject>
-(NSDictionary *) detailController:(DetailController *)sender nextDetailsForCurrent:(NSDictionary *)current;
@end
Give the detail view controller a property like this:
@property (nonatomic,assign) id<DetailDelegate> delegate;
Notice the assign
instead of retain
. By convention a delegate is not retained, even though it must remain valid for the life of the other object. The id form just means the object conforms to the protocol.
When the table view controller creates the details view controller, it sets itself as the delegate.