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

2019-09-05 00:21发布

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.

3条回答
我想做一个坏孩纸
2楼-- · 2019-09-05 00:51

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];
查看更多
Bombasti
3楼-- · 2019-09-05 00:54

why don't you use NSUserDefaults??

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

查看更多
聊天终结者
4楼-- · 2019-09-05 01:18

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

查看更多
登录 后发表回答