DirectX
DirectX

Reputation: 952

How can I protect a portion of my app from certain users (ie. one of the tabbed views can only be seen by certain users)

I am building my first iOS app (other than just samples etc) that I will try to put on the app store. I will make this for iPhone/ipad and using iOS 5.0.

I was thinking of having my app have tabbed views. I will have a basic users and a "member" user. The member user would have access to a feature/view/data that a basic user does not. I am looking for two things. One, some ideas on a best way to protect/hide this from the basic user and two, some technical code help too on how to do it. I have had an idea that I could possibly have one pin code that all members know or even do an id/password where I keep that info in a plist or something and then I could in viewdidload (maybe?) cause a modal view to come up and challenge the person before letting them see the view/data.

Looking for any ideas.

Upvotes: 1

Views: 192

Answers (2)

Jeffery Thomas
Jeffery Thomas

Reputation: 42578

I would not recommend a preset password approach. You will find the baked-in username and password posted on message boards almost instantly. You will want to use either a web-service for authentication or have it be an in-app purchase.

Upvotes: 2

David Hoerl
David Hoerl

Reputation: 41622

Implement this delegate method, then use logic to decide whether to return YES or NO:

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
Parameters
tabBarController
The tab bar controller containing viewController.
viewController
The view controller belonging to the tab that was tapped by the user.
Return Value
YES if the view controller’s tab should be selected or NO if the current tab should remain active.

Discussion
The tab bar controller calls this method in response to the user tapping a tab bar item. You can use this method to dynamically decide whether a given tab should be made the active tab.

Upvotes: 1

Related Questions