bridging

NS_REFINED_FOR_SWIFT and return value

拟墨画扇 提交于 2019-12-18 09:22:39
问题 I'm new with Swift and I begin exploring some feature for bridging with Objective-C. Currently I have a method with NSError reference which is: - (BOOL) verifyPersonalizationWithError:(NSError **) error NS_REFINED_FOR_SWIFT; Now I can access the method in Swift for some refinements, but the return value is lost. The generated method for Swift is: open func __verifyPersonalization() throws The error is correctly handled with the do catch but the return value seems to be lost. Any missing thing

[iOS开发]Swift调用Objective-C代码

与世无争的帅哥 提交于 2019-11-30 23:30:21
本文写于2014.09.25 最近iOS开发之新编程语言Swift在iOS开发圈内反响比较大,国内外都有很多教程或小示例。 虽然Swift这门语言仍然在不断的进化之中,而且变动还是比较大,苹果公司也不承诺目前所写代码会在将来兼容,但仍挡不住iOS开发者的热情。 为什么要使用Swift调用Objective-C代码 目前Swift语言所编写的应用才刚刚可以使用Xcode 6 GM版本提交,而Objective-C作为苹果的主开发语言存在了很多年了。目前尚无成熟的Swift库可用,所以当前编写应用可以说基本离不开调用Objective-C代码的情况。 如何去调用Objective-C代码 目前苹果给出的解决方案是使用一个Bridging-Header头文件,将所要使用的Objective-C代码的头文件引用进来。其中Xcode自动生成的头文件名形式会是以项目名-Bridging-Header.h这样的形式。但是,这个文件名格式并不是必须的,你可以自由定义。 Xcode自动生成方案 新建一个Swift项目,是不会自动生成调用Objective-C的头文件的。但是,可以在项目中,新建一个Objective-C的文件,这时候,Xcode会提示你,是否生成一个相应的头文件来使Swift调用。选择 是 ,这时候就是自动生成一个上面所说格式的头文件。你可以把新建的空Objective-C文件删除

NS_REFINED_FOR_SWIFT and return value

最后都变了- 提交于 2019-11-29 15:52:32
I'm new with Swift and I begin exploring some feature for bridging with Objective-C. Currently I have a method with NSError reference which is: - (BOOL) verifyPersonalizationWithError:(NSError **) error NS_REFINED_FOR_SWIFT; Now I can access the method in Swift for some refinements, but the return value is lost. The generated method for Swift is: open func __verifyPersonalization() throws The error is correctly handled with the do catch but the return value seems to be lost. Any missing thing for my NS_REFINED_FOR_SWIFT macro? This is unrelated to the NS_REFINED_FOR_SWIFT macro. The Objective