我有一个继承自 UILocalNotification
的自定义类,它有一个 Store
对象属性(继承自 NSObject
的类):
customLocalNotification.h:
@property (strong,nonatomic) 存储 *store;
但是当我尝试像这样在 viewController
中设置“Store”对象时:
customLocalNotification *notification=[[customLocalNotification alloc] init];
notification.store=store; //Crashes here
编辑:我将使用 userInfo
字典来保存我的 Store
对象,但是当我尝试这样做时,它会因此错误而崩溃留言:
2016-02-11 15:55:26.132 App[13861:3606796] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'unable to serialize userInfo: Error Domain=NSCocoaErrorDomain Code=3851 "roperty 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 -[UIConcreteLocalNotification userInfo] + 0
3 App 0x00000001088cb65b -[monitorLocationViewController createNotificationWithStore:andArounders:] + 683
4 App 0x00000001088cb1ed -[monitorLocationViewController sendNotificationIfNeededForStore:] + 397
5 App 0x00000001088cb021 -[monitorLocationViewController locationManager:didEnterRegion:] + 145
6 App 0x00000001088cae9c __68-[monitorLocationViewController locationManager:didUpdateLocations:]_block_invoke + 284
7 CoreFoundation 0x000000010c0f59ff __51-[__NSSetM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 79
8 CoreFoundation 0x000000010c0f590a -[__NSSetM enumerateObjectsWithOptions:usingBlock:] + 202
9 App 0x00000001088cad02 -[monitorLocationViewController locationManager:didUpdateLocations:] + 402
10 CoreLocation 0x000000010a8c5177 CLClientGetCapabilities + 20882
11 CoreLocation 0x000000010a8c15d3 CLClientGetCapabilities + 5614
12 CoreLocation 0x000000010a8bc0cd CLClientInvalidate + 923
13 CoreFoundation 0x000000010c0c2a1c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
14 CoreFoundation 0x000000010c0b86a5 __CFRunLoopDoBlocks + 341
15 CoreFoundation 0x000000010c0b7e02 __CFRunLoopRun + 850
16 CoreFoundation 0x000000010c0b7828 CFRunLoopRunSpecific + 488
17 GraphicsServices 0x000000010ed92ad2 GSEventRunModal + 161
18 UIKit 0x000000010c543610 UIApplicationMain + 171
19 App 0x00000001088dedef main + 111
20 libdyld.dylib 0x000000010dbbe92d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
有人知道为什么会崩溃吗?
谢谢!
UILocalNotifications
旨在包含一些轻量级数据。也就是说,userInfo
可以包含 property list encodable仅限项目。而且我要补充一点,整个事情并不是为了扔重物而设计的,而只是传递一些上下文信息,当通知到达时您需要处理这些信息(即一些标识符、数字等)。
关于ios - "unrecognized selector sent to instance"属性 setter ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35340798/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |