gpt4 book ai didi

objective-c - 在登录页面获取用户 ID

转载 作者:行者123 更新时间:2023-11-29 05:02:50 25 4
gpt4 key购买 nike

如何将用户 ID 从登录页面传递到结束页面以允许用户访问我的应用程序?我想做一个像雅虎这样的应用程序;如果我们打开一个雅虎页面,并输入我们的用户名和密码进行登录,那么无论我们走到哪里都不会出现任何问题。如果我们想更新我们的个人资料,我们可以轻松做到。我希望我的 iPhone 应用程序也能如此;用户登录后,我就可以在整个应用程序中使用该 ID,如果用户想要更新,那么他可以轻松更新服务器数据库中的值。

最佳答案

如果您了解应用程序委托(delegate),那么您可以这样做,声明一个变量,假设用户 ID 是整数,如下所示。

@interface YourAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
LenseCareViewController *viewController;
NSInteger intUserID;
}
@property (nonatomic,readwrite) NSInteger intUserID; //Synthesize this variable in implementation

//Your Header File
#import "YourAppDelegate.h"

@interface YourViewController : UIViewController
{
YourAppDelegate *appDelegate;
}

@property(nonatomic,retain) YourAppDelegate *appDelegate;

@end

//Your Implementation file
@implementation YourViewController
@synthesize appDelegate

- (void)viewDidLoad {
self.appDelegate = (YourAppDelegate*) [[UIApplication sharedApplication] delegate];
self.appDelegate.intUserID = 5; //Assign value to this variable and you can have access globally.
}

@end

希望有帮助。如有疑问请留言。

关于objective-c - 在登录页面获取用户 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6463749/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com