Closed chadmoone closed 8 years ago
It' looks like aforementioned non-recomended behaviour breaks when delegate is implemented in Swift.
#0
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x000001a1a0435f18
Raw
0 libobjc.A.dylib
lookUpImpOrForward + 80
1 libobjc.A.dylib
_objc_msgSend_uncached_impcache + 56
2 SwiftGift
iRate.m line 657
-[iRate connectionError:]
3
Foundation
__NSThreadPerformPerform + 340
9
UIKit
UIApplicationMain + 204
10 SwiftGift
main.m line 14
main
@nicklockwood any chance to merge this? It looks like very appropriate change.
@nicklockwood any updates? This is an actual intermittent crashing bug for any swift implementation (theoretically objc as well). The PR changes no API or functionality, but simply avoids using the recommended-against and dangerous technique.
This is currently the #2 crash in a popular production app. I think this library is great, but I'm going to have to fork this permanently or roll our own if we can't get this resolved.
Declaring these methods as optional and then calling them without testing whether they have been implemented can cause crashes in any delegate class where the methods are not implemented.
The current workaround in iRate, which declares a category on
NSObject
to prevent these crashes, is invalid as per the Apple documentation and can result in undefined behavior:This PR does not change any functionality, but will prevent any conditions of undefined behavior.