2015-03-1717:25:55.249MyProject[36665:3189330] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MyProject.Demo onRequestCompleted:]: unrecognized selector sent to instance 0x7f9fd3df1d00'
百思不得其解只能求助文档和 Stackoverflow 了,因为这个错误太普遍,而且在 swift 中很多人还没有去踩坑。所以花了很长的时间才发现,原来在我们的文档中有这样的一段:
To be accessible and usable in Objective-C, a Swift class must be a descendant of an Objective-C class or it must be marked @objc.
Swift declarations marked with the private modifier do not appear in the generated header. Private declarations are not exposed to Objective-C unless they are explicitly marked with @IBAction,@IBOutlet, or @objc as well.