wanted to see if somebody can provide some suggestions/pointers on how to address this issue I am currently facing for an iPad app. Here is a link to the graphic that I am describing below
http://www.yogile.com/dsruyzk7/41m/share/?vt=QANtu4j
Basically I have a parentViewController which contains 2 child view controllers. Child 1 has a UITableView and
Child 2 has a custom UIView. I am able to load the info from UITableview on Child 1 to the custom UIView on Child 2 from didSelectRowAtIndexPath. After the data is
displayed on Child 2 I do some processing. After the processing is complete, I need to update the UITableView on Child 1 so that the new/updated data
gets displayed on the UITableView. I tried creating a delegate on Child 1 but wasn’t working maybe I set something wrong. So any help suggestion would be greatly appreciated.
Thanks
.h on Child 2 ViewController
@class Child2ViewController;
@protocol child2Delegate <NSObject>
- (void)refreshTable:(Child2ViewController*)controller passedDict:(NSDictionary *)dict;
@interface Child2ViewController:UIViewController<UITableViewDataSource, UITableViewDelegate> {
UITableView *myTableView;
id<child2Delegate> delegate;
Child1ViewController *child1VC;
}
@property (nonatomic, weak) id<child2Delegate> delegate;
…
…
@end
.m on Child 2 ViewController
@synthesize delegate;
…
..
..
#after all the processing is done we are ready to refresh the view
#updatedDictForTableView is basically a NSDictionary and has the updated data needed
#for the UITableview on child1VC.
-(void)processData {
child1VC.delegate = self
NSLog(@"Dump the updated Data : %@", updatedDictForTableView);
[delegate refreshTable:self passedDict:updatedDictForTableView;
}
.h in Child1 ViewController
@interface Child1ViewController : UIViewController <child2Delegate> {
….
….
..
}
.m in Child1 ViewController
- (void)refreshTable:(Child2ViewController*)controller passedDict:(NSDictionary *)dict {
NSLog(@"dump dict %@", dict);
[myTableView reloadData];
}
You can do that without delegate, use NSNotificationcenter to send a notification with your values in the nsdictionary: exple :