Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-12-2011, 07:13 AM   #1 (permalink)
Registered Member
 
DeeJay_CRO's Avatar
 
Join Date: Feb 2011
Location: Osijek, Croatia
Posts: 64
DeeJay_CRO is on a distinguished road
Question Refresh data in UIViewController

Hello!

I have an app with 5 tabs. Four of them holds UIViewController, fifth one is TableViewController.

On fifth tab I have a save function, which changes some data.

However, if I go back on any of these tabs, this data is not refreshed.

I know how to refresh data on tableview, but what would be the best approach with these four UIViewControllers. How to refresh data on them?

Thanks a lot!

Cheers!
DeeJay_CRO is offline   Reply With Quote
Old 05-12-2011, 07:20 AM   #2 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 41
prudhvi is on a distinguished road
Default

Hi Deejay,can you send your code..
prudhvi is offline   Reply With Quote
Old 05-12-2011, 07:39 AM   #3 (permalink)
Registered Member
 
DeeJay_CRO's Avatar
 
Join Date: Feb 2011
Location: Osijek, Croatia
Posts: 64
DeeJay_CRO is on a distinguished road
Default

Quote:
Originally Posted by prudhvi View Post
Hi Deejay,can you send your code..

During application startup, I'm setting town name as:

Code:
MySingleton *sharedInstance = [MySingleton sharedInstance];
sharedInstance.townName = @"New York";

On all tabs, I'm using the same singleton instance to show town name:

Code:
[townName setText:sharedInstance.townName];
Singleton is 100% ok, (made "by the book") since I'm using this townName in all 5 tabs and all of them shows the townName set during application startup.



But if I change townName, and save it:
Code:
MySingleton *sharedInstance = [MySingleton sharedInstance];
sharedInstance.townName = @"Chicago";
and change a view by selecting any of the tabs, the old value is still shown.

I need to refresh data, to have a new town name on all tabs after save.
DeeJay_CRO is offline   Reply With Quote
Old 05-12-2011, 07:53 AM   #4 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 41
prudhvi is on a distinguished road
Default

did u store all the tabs in an array?then create a property for it to access anywhere.then after saving change the text of all tabs by running a loop using that array count.
prudhvi is offline   Reply With Quote
Old 05-12-2011, 08:46 AM   #5 (permalink)
Registered Member
 
DeeJay_CRO's Avatar
 
Join Date: Feb 2011
Location: Osijek, Croatia
Posts: 64
DeeJay_CRO is on a distinguished road
Default

Quote:
Originally Posted by prudhvi View Post
did u store all the tabs in an array?then create a property for it to access anywhere.then after saving change the text of all tabs by running a loop using that array count.
No,I didn't. I thought that maybe is existing some "authomatic" mechanism (like invoking re-building a view - or something like that), since I have 30-40 variables to refresh (not only town name).

However, thanks for the answer - I will do it in that way.

Cheers!
DeeJay_CRO is offline   Reply With Quote
Old 05-12-2011, 08:57 AM   #6 (permalink)
Registered Member
 
DeeJay_CRO's Avatar
 
Join Date: Feb 2011
Location: Osijek, Croatia
Posts: 64
DeeJay_CRO is on a distinguished road
Default

Quote:
Originally Posted by DeeJay_CRO View Post
No,I didn't. I thought that maybe is existing some "authomatic" mechanism (like invoking re-building a view - or something like that), since I have 30-40 variables to refresh (not only town name).

However, thanks for the answer - I will do it in that way.

Cheers!
Or, what do you say for this solution:

1) make a separate method for setting gui labels (for each view - one such method)
2) call it "normally" in viewDidLoad - for each view the same
3) set some flag that data is changed - for each view - separate flag
4) on each view controller, in viewWillAppear, check view's flag
5) if data is changed, load all data for the view (call that separate method) and reset view's flag.

In that way it could be assured that every view refreshed (and only once) for each data saving.
DeeJay_CRO is offline   Reply With Quote
Reply

Bookmarks

Tags
refresh, uiviewcontroller

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 361
6 members and 355 guests
doffing81, dre, iOS.Lover, Kirkout, MikaelBartlett, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:02 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0