views:

20

answers:

1

Hello,

I'd like to add a function to my app where users can select favorites. I've got a list with games and I want a button in my tabbar saying: "Add". Now this isn't a problem. But when you click add, I'd like a modal view to come up in which you can select multiple games (which then show the CheckmarkAcessory). And If you then click add it should add these NSStrings to a NSMutableArray which I've got set up. Now my whole code is working, but this is the last thing.

If anyone, could describe (quite simple) or provide me a link to a tutorial showing how to do this I would be very greatful! I'm just starting with making apps, so sometimes I have issues determining in which method to place code. So please, keep it simple and help me out here!

I would be grateful,

Fabian

B.T.W., this app has a Tab bar as rootcontroller, includes a Nav controller and a TableViewController.

Update:

Thank you very much for answering me, now with this helpful information I'd probably be able to pop up the modal view when the person clicks "Add" in the tab bar. So I'll have another TableView which I'll then present in the modal view (the myViewController), but what do I need to implement in the myViewController so it has a UITableView in which you can select multiple games at once and click done to add them all to the NSMutableArray called favorites? How do I make the didSelectRow:atIndexPath method so that it has this functionality?

So It should be a tableView in which the user selects multiple games to add to the favoritesArray at once. I really can't figure out the code to do that. Any help oon this would be greatly appreciated!

BTW. I didn't already have the myViewController because I don't know how to implement the option to select multiple games and add checkmarks to them and then add them to the mutable array.

A: 

The easiest way to pop a modal view is to use UIViewController's presentModalViewController.

So, I am assuming you already have UIViewController to select multiple games (supposed it's called myViewController), and you want to present it from your main view controller (which from your post seems to be the rootcontroller). Simply add the following:

[rootController presentModalViewController:myViewController animated:YES];

When you are done with the modal view controller, simply dismiss it with:

[myViewController dismissModalViewControllerAnimated:YES];

You should then be able to extract the strings received from myViewController and add them to the NSMutableArray

Link for the API reference

presentModalViewController

http://developer.apple.com/iphone/library/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/presentModalViewController:animated:

dismissModalViewController

http://developer.apple.com/iphone/library/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/dismissModalViewControllerAnimated:

kmcgrady
Thanks for this answer! See my edited question for some more help I need.. thanks in advance!