-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
why not support NSDictionary as NSUserDefault #10
Comments
Mainly because NSDictionary's value type is uncertain, it's hard to encode/decode NSDictionary properly in protobuf, if not possible. However, you can turn a NSDictionary into a NSData by NSArchive, and store that NSData in MMKV. |
+1 |
NSUserDefault can read/write NSDictionary directly, and MMKV needs to do a conversion through NSArchive. If you consider the consumption of conversion, is the performance advantage of MMKV still greater than NSUserDefault? |
Well, NSUserDefault's NSDictionary support doesn't come in free. Which algorithm do you think it used to store NSDictionary? NSArchive? I haven't test it yet, but that's my best guess. Given that guess, I have confidence MMKV will beat NSUserDefault in such case. |
thx~ |
you tell me I should better convert dictionary or Nsarray to NSData ,not the jsonStr , the reason is ( value type is uncertain, it's hard to encode/decode NSDictionary properly)? when I conert to jsonStr , all is NSString , |
Use NSData for efficiency, or JSON for convenience. It's your choice. |
其实可以提供一个直接存 NSDictionary 的 api。然后内部进行一步转换~你觉得呢? |
Maybe. |
Supported with #78 , checkout release note. |
The language of MMKV
Objective-C
The version of MMKV
v1.0.10
The platform of MMKV
iOS
The installation of MMKV
Cocoapods
What's the issue?
For me, I often use a NSUserDefault to do some simple data persistence. And the NSDictionary is a very important one. Why is there no support for it?
The text was updated successfully, but these errors were encountered: