1

I am building a application like RunKeeper (http://www.raywenderlich.com/73984/make-app-like-runkeeper-part-1). Please forgive me if I am using the incorrect language to describe what I am trying to do as I am learning swift, and new to iPhone development :-).

I am planning on using the UIPageViewController with 3 pages. On the first page, I would like to show the running timer, Start, Pause, Finish, Lap, etc buttons. Once the timer is running, when the user press the 'Lap' button on the first page, I would like the lap log information to be shown in a table on the second page. The system should not switch pages unless the user swipes the page. On the third page should be the map with GPS. I want to take information from the gps (on the third page), and perform some processing on that data, and show the results on the second page.

My question is, how do I share or pass that information from the first, and third page to the second page without the page changing to the second page? Note: the app should not switch pages when the data goes from the first, third page to the second. It should only switch pages if the user swipes. Second question is, once the data is available to the second controller, can I execute functions while the page is still on the first or third page?

I've tried to use segue, but the app switch from the first, third page to the second page when prepareForSegue is called. I also tried using global data (just to try to get it working), but the data is not updated when I swipe to the second page.

Please let me know if I need to explain something more clearly.

Thank you for your time.

Jessie
  • 19
  • 3

1 Answers1

0

I started a thread to discuss various ways you can share data between view controllers in Swift:

How do you share data between view controllers and other objects in Swift?

In your case a data container singleton would probably be a good choice. You'd need to add code in your viewWillAppear method that fetches new values from the singleton and displays them so that your view controllers display the latest data when the user swipes to one of the other view controllers.

Community
  • 1
  • 1
Duncan C
  • 128,072
  • 22
  • 173
  • 272