How to make one page pass on a message to another?

2019-09-05 00:36发布

问题:

My problem is different users will have access to different products. Say User 1 has access to 3 whereas User 2 has access to all 4.

Can I have something upon Login where if User 1 logs in, it will tell the MainView to only show 3 cells? Something like ViewDidLoad in the MainView to read what the Login Page echo-ed?

Can that be done?

Thanks.

回答1:

Store a global variable in appdelegate like numberOfCells. Assign value to it by the condition of your login.

Once your MainView is about to display like in viewWillAppear, get the value of numberOfCells from appdelegate and chage your UI.

You can get the appdelegate reference as follows.

SampleAppDelegate *appdelegate=(SampleAppDelegate*)[[UIApplication sharedApplication] delegate];


回答2:

If you keep track of the user who has 'logged-it' you can configure your views based on that user/profile.



回答3:

why don't you use NSUserDefaults??

You can save alot of field in it and will be accessible throughout your project.