ios - "unrecognized selector sent to instance"属性 setter
<p><p>我有一个继承自 <code>UILocalNotification</code> 的自定义类,它有一个 <code>Store</code> 对象属性(继承自 <code>NSObject</code> 的类):</p>
<p><strong>customLocalNotification.h</strong>:</p>
<p><code>@property (strong,nonatomic) 存储 *store;</code></p>
<p>但是当我尝试像这样在 <code>viewController</code> 中设置“Store”对象时:</p>
<pre><code>customLocalNotification *notification=[ init];
notification.store=store; //Crashes here
</code></pre>
<p><strong>编辑</strong>:我将使用 <code>userInfo</code> 字典来保存我的 <code>Store</code> 对象,但是当我尝试这样做时,它会因此错误而崩溃留言:</p>
<pre><code>2016-02-11 15:55:26.132 App *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'unable to serialize userInfo: Error Domain=NSCocoaErrorDomain Code=3851 "Property list invalid for format: 200 (property lists cannot contain objects of type 'CFType')" UserInfo={NSDebugDescription=Property list invalid for format: 200 (property lists cannot contain objects of type 'CFType')}'
*** First throw call stack:
(
0 CoreFoundation 0x000000010c196e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010bc0fdeb objc_exception_throw + 48
2 UIKit 0x000000010cbd5ba5 - + 0
3 App 0x00000001088cb65b - + 683
4 App 0x00000001088cb1ed - + 397
5 App 0x00000001088cb021 - + 145
6 App 0x00000001088cae9c __68-_block_invoke + 284
7 CoreFoundation 0x000000010c0f59ff __51-_block_invoke + 79
8 CoreFoundation 0x000000010c0f590a - + 202
9 App 0x00000001088cad02 - + 402
10CoreLocation 0x000000010a8c5177 CLClientGetCapabilities + 20882
11CoreLocation 0x000000010a8c15d3 CLClientGetCapabilities + 5614
12CoreLocation 0x000000010a8bc0cd CLClientInvalidate + 923
13CoreFoundation 0x000000010c0c2a1c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
14CoreFoundation 0x000000010c0b86a5 __CFRunLoopDoBlocks + 341
15CoreFoundation 0x000000010c0b7e02 __CFRunLoopRun + 850
16CoreFoundation 0x000000010c0b7828 CFRunLoopRunSpecific + 488
17GraphicsServices 0x000000010ed92ad2 GSEventRunModal + 161
18UIKit 0x000000010c543610 UIApplicationMain + 171
19App 0x00000001088dedef main + 111
20libdyld.dylib 0x000000010dbbe92d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
</code></pre>
<p>有人知道为什么会崩溃吗?</p>
<p>谢谢!</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p><code>UILocalNotifications</code> 旨在包含一些<strong>轻量级</strong>数据。也就是说,<code>userInfo</code> 可以包含 <a href="https://developer.apple.com/library/ios/documentation/General/Conceptual/DevPedia-CocoaCore/PropertyList.html#//apple_ref/doc/uid/TP40008195-CH44" rel="noreferrer noopener nofollow">property list encodable</a>仅限项目。而且我要补充一点,整个事情并不是为了扔重物而设计的,而只是传递一些上下文信息,当通知到达时您需要处理这些信息(即一些标识符、数字等)。</p></p>
<p style="font-size: 20px;">关于ios - "unrecognized selector sent to instance"属性 setter ,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/35340798/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/35340798/
</a>
</p>
页:
[1]