Reputation: 4487
How do we "queue" ViewControllers to be pushed one by one?
My app check for number of "Friend Requests" and I would like to push one by one from one to another.
Check for Requests
Found 3 Requests
Push FriendRequestViewController
User Press OK
Push Another FriendRequestViewController
User Press OK
Push Another FriendRequestViewController
Done
I've tried using loop but it would just push three viewcontrollers right away from the currentViewController.
for request in friendRequests
{
let friendRequestViewController = FriendRequestViewController();
friendRequestViewController.request = request;
self.navigationController.presentViewController(friendRequestViewController);
}
Any idea? Thanks you
Upvotes: 1
Views: 56
Reputation: 1407
I can think of something like declaring protocol
protocol FriendRequestControllerDelegate {
func friendRequestContollerConfirmed(friendRequestController : FriendRequestViewController)
}
Then, in object that presents friend request
//somewhere you have requestsEnumerator
func friendRequestContollerConfirmed(friendRequestController : FriendRequestViewController) {
request = requestsEnumerator.nextObject();
if request {
let friendRequestViewController = FriendRequestViewController();
friendRequestViewController.request = request;
friendRequestViewController.delegate = self;
self.navigationController.presentViewController(friendRequestViewController);
}
}
And where you first present friend request just call this function
In FriendRequestController make itself a target for yours Ok button.
func okButtonTapped() {
if(self.delegate.respondsToSelector:Selector(friendRequestContollerConfirmed)) {
self.delegate.friendRequestContollerConfirmed(self)
}
}
Upvotes: 1