ios - "unrecognized selector sent to instance"属性 setter

标签 ios objective-c cocoa-touch unrecognized-selector

我有一个继承自 UILocalNotification 的自定义类,它有一个 Store 对象属性(一个继承自 NSObject 的类):

customLocalNotification.h:

@property (strong,nonatomic) Store *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 "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 -[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/

相关文章:

ios - Swift 字符串插值性能

cocoa - 加载本地化的 UIImage

objective-c - 在 MKMapView 中顺畅地跟踪用户的位置

objective-c - ARC 在哪里写发布指令?

iphone - UISearchDisplayController 不显示任何单元格

ios - 出现 View 时在表中加载新数据

iphone - iOS 应用程序上的 Facebook 登录

html - 用于格式化 html 的 iOS 库

jquery - Safari iOS 9.0.2 jquery 错误与.css 左/右

ios - 当用户滚动相邻的 UIScrollView 时,我的 UIView 子类不调用 drawRect