tags:

views:

48

answers:

1

hi friends...

i have been searching a solution for this problem... but i didnt get it....

I have an app in which there is a tabbarcontroller with two views added to the viewcontrollers array of it. . one a list view and another a view to add items to the list.. apart from this tabbarcontroller i have a edit viewcontroller which is pushed in to the navigation controller when tapped on one of the items of the list view in the tabbarcontroller. this edit view controller is used to update the values in the list view.

what my need is updating the list view in the tabbarcontroller when i go back from the edit view controller... Pls any one suggest me a solution...

A: 

I'd consider using notifications. When your edit controller detects an edit action, you could fire a notification off and the list view controller should be registered to listen for that notification. The edit view controller could pass the new list contents in the notification.

Have a look at the notification center documentation for more info.

e.g.

// In some .h file somewhere
#define kListHasBeenEditedNotification @"listHasBeenEditedNotification"

...
// Inside your list view controller
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(listUpdated:)
                                             name:kListHasBeenEditedNotification
                                           object:nil];

- (void) listUpdated:(NSNotification *)note {
    // Deal with the list data (which is in [note.userInfo objectForKey:@"listItems"]
    ...
}



...
// After an edit has been done (inside your edit view controller)
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:listItems, @"listItems", nil];
[[NSNotificationCenter defaultCenter] postNotificationName:kListHasBeenEditedNotification
                                                    object:self
                                                  userInfo:userInfo];
deanWombourne