ios - 将 NSDictionary(带有自定义类)保存到 NSUserDefaults
<p><div>
<aside class="s-notice s-notice__info post-notice js-post-notice mb16"role="status">
<div class="d-flex fd-column fw-nowrap">
<div class="d-flex fw-nowrap">
<div class="flex--item wmn0 fl1 lh-lg">
<div class="flex--item fl1 lh-lg">
<b>这个问题在这里已经有了答案</b>:
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您的代码似乎不错。我找不到错误所以尝试换行:</p>
<pre><code>self.myDictionary = ;
</code></pre>
<p>到</p>
<pre><code>id unknownObject = ;
NSLog(@"%@",);
</code></pre>
<p>看看@控制台。如果输出是字典,也许你也应该尝试强制转换。所以尝试将其更改为:</p>
<pre><code>self.myDictionary = (NSDictionary*);
</code></pre>
<p><strong>编辑</strong></p>
<pre><code>NSDictionary *dictionary = ;
NSLog(@"before: %@",dictionary);
NSData *myData = ;
NSDictionary *myDictionary = (NSDictionary*) ;
NSLog(@"after: %@",myDictionary);
</code></pre>
<p>输出:</p>
<pre><code>2013-11-13 14:32:31.369 DemoM before: {
key1 = object1;
key2 = object2;
key3 = object3;
}
2013-11-13 14:32:31.372 DemoM after: {
key1 = object1;
key2 = object2;
key3 = object3;
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 将 NSDictionary(带有自定义类)保存到 NSUserDefaults,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/19954845/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/19954845/
</a>
</p>
页:
[1]