- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我收到的完整错误消息:
作为NSUserDefaults/CFPreferences
键的值 Login_Data
2019-04-02 09:44:56.191207+0530 Level Up[238:4101] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to insert non-property list object
这是我的代码:
let data = response.result.value as! NSDictionary
print(data)
if data["error-code"] != nil {
if data.object(forKey: "error-code")as! String == "\(200)"
{
let arrTimer = ((data.object(forKey: "data") as! NSDictionary).object(forKey: "timers") as! NSArray).mutableCopy() as! NSMutableArray
UserDefaults.standard.set(arrTimer , forKey: "ArrayTimer")
UserDefaults.standard.set((data.object(forKey: "data") as! NSDictionary), forKey: "Login_Data")
我在从后端更改用户电子邮件时收到此消息。对于新用户来说效果很好。我希望这些代码足以让您了解我正在尝试做什么。
最佳答案
看起来问题是字典有 NSNull 或 nil 值,并且尝试将其存储在 UserDefaults 中不起作用。该库可能应该使用 NSKeyedArchiver 来解决这个问题。将字典转换为数据,然后将其保存在 UserDefaults 中。
关于swift - 我收到此错误 "Attempt to set a non-property-list object as an NSUserDefaults",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55467020/
我对 NSUserDefaults 的 standardUserDefaults 有疑问。standardUserDefaults 方法到底做了什么?是在初始化对象吗? 最佳答案 是或否。 NSUse
我的应用程序涉及用户能够拖动特定项目,例如音量 slider 和 UIImage View 。我的目标是能够保存项目的位置,以便用户在重新启动后不必再次拖动项目。不幸的是,我在使用“保存 CGRect
有谁知道通过 NSLog 转储 NSUserDefaults 的 standardUserDefaults 的快速方法?这是我的: NSLog(@"NSUserDefaults dump: %@",
我的主菜单 (MainMenu.xib) 中有一个名为“Word Wrap”的 NSMenuItem。它的值绑定(bind)到我的共享用户默认 Controller ,也在 XIB 中实例化。选中时它
App Programming Guide for tvOS简要说明: Apple TV上没有用于应用程序的持久本地存储。这意味着为新的Apple TV开发的每个应用程序都必须能够在iCloud中存储
苹果的文档说 NSUserDefaults temporarily disables sudden termination to prevent process killing between the
我使用 NSUserDefaults 来存储一些东西。 它工作正常,但只有在我重新启动应用程序后。 我使用:[首选项同步];我以为它会立即保存数据,但首选项保持为空。 如果您有任何想法或已经处理过它,
在有人说这个问题之前已经被问过很多次之前,我已经浏览了大约 20 个不同的答案,并尝试了我发现的所有内容。尽管如此,我大约 5 天前才开始使用 Objective C,所以可能有一些非常简单的解决方案
我试图在应用程序第一次启动时显示警报。如果他们稍后进入设置页面并希望再次看到它,我还想显示此警报。我想我可以在 NSUserDefaults 中设置一个 bool 值。我不太确定如何做到这一点(假设这
在我的 viewWillLoad: 方法中,我目前正在执行以下操作: - (void)viewWillAppear:(BOOL)animated { NSUserDefaults *defaul
我将一个整数值传递给 NSUserDefault 对象来存储,以便在我的应用程序加载时使用。我HAD它工作得很好,直到我尝试将该整数值切换为 float 。它导致了一大堆问题,所以我重新调整了我的方法
我在 Settings.bundle 中保存了一些设置,并且尝试在 application:didFinishLaunchingWithOptions 中使用它们,但在模拟器上首次运行时,通过按键访问
数组如何保存到 NSUserDefaults 中? 我有以下代码尝试存储 NSURL 数组 NSArray *temp = [[NSArray alloc] initWithArray:[mySing
NSUserDefaults 的同步方法何时以及为何失败?确保我的值实际写入并提交给 NSUserDefaults 的最佳方法是什么,这样我在应用程序重新启动后恢复状态就不会遇到任何问题? 最佳答案
我对 NSUserDefaults 有疑问,并且不太明白发生了什么。 我的应用程序有 5 个级别,每个级别都与 NSUserDefaults 执行完全相同的操作(检索级别默认值,在用户玩该级别时更改值
我能够使用 NSUserDefaults 存储、检索和删除值。我无法成功找到 NSUserDefaults 在 iPhone 上的物理存储位置?我猜它应该是 plist 文件,但不确定。有谁知道是否可
谁能告诉我 NSUserDefaults 的最大大小。意味着我们可以存储在用户默认值中的对象或基元。例如 10 MB 等。 谢谢 最佳答案 不,除了设备本身的存储容量之外,NSUserDefaults
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: How can I reset the NSUserDefaults data in the iPhone simu
每次向 plist 写入任何内容时,我都会使用 [[NSUserDefaults standardUserDefaults] Synchronize] 。这太过分了吗?或者这样做会产生不良影响吗? 最
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:@"xxxxxxxx" fo
我是一名优秀的程序员,十分优秀!