在我的 .h 上:
@property (weak, nonatomic) IBOutlet UILabel *user;
@property (weak, nonatomic) IBOutlet UILabel *pass;
@property (weak, nonatomic) IBOutlet UILabel *mail;
-(void)setValuesFromPrefrences;
在我的 .m 上:
#define kUser @"user"
#define kPass @"pass"
#define kMail @"mail"
- (void)setValuesFromPrefrences {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSDictionary *initialDefaults=[[NSDictionary alloc]
initWithObjectsAndKeys:
@"Username", kUser,
@"Password", kPass,
@"Mail", kMail,
nil];
[userDefaults registerDefaults: initialDefaults];
self.user.text = [userDefaults stringForKey:kUser];
self.pass.text = [userDefaults stringForKey:kPass];
self.mail.text = [userDefaults stringForKey:kMail];
}
- (void)viewDidLoad {
[self setValuesFromPrefrences];
[super viewDidLoad];
[self setTitle:@"FEED"];
[self refreshStream: @"1" user:@"user" pass:@"pass" mail:@"mail"];
}
如何从用户那里获取值,传递并邮寄到该行:
[self refreshStream: @"1" user:@"user" pass:@"pass" mail:@"mail"];
现在代码将在标签上写入值,并且它可以工作 - 总线我想使用 refreshStream 中的值。