views:

103

answers:

2

I have data being refreshed in a modalViewController and when that data gets refreshed, the parent controller needs to refresh its data as well. I tried doing a [tableView reloadData]; but it didn't work properly since the actual array values aren't being refreshed. Is there a way for me to reload a controller without the user seeing any animation?

Thanks for any help!

A: 

The underlying view can get released while the modal view is showing, so you shouldn't try to modify it directly. Instead, you can use the viewWillAppear: method on the main view controller to make any necessary updates.

I'm not sure what you mean that "the actual array values aren't being refreshed". How the two view controllers exchange data depends a lot on what you are trying to accomplish. If the modal view is only used in one place, the main controller can access its properties directly. Or maybe you want a dedicated class to hold the state... Again, depends on the context.

Felixyz
+1  A: 

Are you refreshing the data off the main thread? If so, you need to call the reloadData method using the following method:

- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait

So for a tableView it would be something like:

[tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];

xmr