如何使 NSUserDefaults 数据持续 3 个会话
我有这段代码
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (![defaults objectForKey:@"firstRuns"]){
[defaults setObject:[NSDate date] forKey:@"firstRuns"];
if ([cellValue isEqual: @"First"] || [cellValue isEqual: @"Primo"]){
cell.backgroundColor = [UIColor yellowColor];
} else {
cell.backgroundColor = [UIColor whiteColor];
}
}
[[NSUserDefaults standardUserDefaults] synchronize];
,以便
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
将名为“Primo”或“First”的行的背景设置为黄色,以便用户第一次使用。
我希望黄色背景至少持续 3 个会话,我该怎么做?谢谢
I have this piece of code
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (![defaults objectForKey:@"firstRuns"]){
[defaults setObject:[NSDate date] forKey:@"firstRuns"];
if ([cellValue isEqual: @"First"] || [cellValue isEqual: @"Primo"]){
cell.backgroundColor = [UIColor yellowColor];
} else {
cell.backgroundColor = [UIColor whiteColor];
}
}
[[NSUserDefaults standardUserDefaults] synchronize];
in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
in order that the background of the row called "Primo" or "First" is set to yellow for the first use of the user.
I want the yellow background to last at least 3 sessions, how can i do that? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样的东西:
Something like:
使用
applicationDidLaunch
中的 UserDefaults:在 tableview 会话中使用该值来触发黄色或白色
Use the UserDefaults in
applicationDidLaunch:
Use that value in your tableview session to trigger yellow or white