我有代码

[target invokeSelector:handler.successAction withObject:object];


它可能会调用一些方法。有无对象。它完全可以在Debug中工作,但在Release中崩溃:

Nov 20 21:55:13 efpies project[7202] <Warning>: >>>> selector: successfulLogin
Nov 20 21:55:13 efpies project[7202] <Warning>: >>>> target: <AppDelegate: 0x1f595a90>
Nov 20 21:55:13 efpies project[7202] <Warning>: >>>> object: <7b226d65 73736167 65223a22 5c753034 31325c75 30343435 5c753034 33655c75 30343334 205c7530 3434305c 75303433 305c7530 3433375c 75303434 305c7530 3433355c 75303434 385c7530 3433355c 75303433 64227d> NSConcreteMutableData
Nov 20 21:55:13 efpies project[7202] <Error>: -[AppDelegate invokeSelector:withObject:]: unrecognized selector sent to instance 0x1f595a90

Nov 20 21:56:12 efpies project[7205] <Warning>: >>>> selector: driversUpdated:
Nov 20 21:56:12 efpies project[7205] <Warning>: >>>> target: <DriversList: 0x1cd5ffd0>
Nov 20 21:56:12 efpies project[7205] <Warning>: >>>> object: (
    ) __NSArrayM
Nov 20 21:56:12 efpies project[7205] <Error>: -[DriversList invokeSelector:withObject:]: unrecognized selector sent to instance 0x1cd5ffd0


这些方法可用(甚至在头文件中也提供)。怎么了?数据和对象是100%正确的

最佳答案

采用

[target performSelector:handler.successAction withObject:object];


这是在可可触摸中执行此操作的方法,因为NSObject将为您处理此操作。
检查Apple documentation了解更多详细信息。

关于objective-c - invokeSelector:withObject:在版本中崩溃,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13479196/

10-12 17:37