简体   繁体   English

如何将Xcode 6.1.1 Swift代码转换为Xcode 6.4 Swift代码?

[英]How to convert Xcode 6.1.1 swift code to Xcode 6.4 Swift code?

Actually, I have implemented the project in Xcode 6.1.1 and Now I want to run the same code on Xcode 6.4 but it's giving me errors as follows : 实际上,我已经在Xcode 6.1.1中实现了该项目,现在我想在Xcode 6.4上运行相同的代码,但是它给我以下错误:

  1. 'AnyObject' is not convertible to 'myObject'; “ AnyObject”不能转换为“ myObject”; did you mean to use 'as!' 您是要使用“ as!”吗? to force downcast? 强迫垂头丧气?
  2. 'countElements' has been renamed to count 'countElements'已重命名为count

And many more. 还有很多。

Is there any provision to remove above errors automatically? 是否有任何条款可以自动删除上述错误? There are 700+ errors after opening the code in Xcode 6.4. 在Xcode 6.4中打开代码后,有700多个错误。 Thanks in advance. 提前致谢。

When you've gone to 6.4, you've also upgraded Swift to 1.2. 当您使用6.4时,还已经将Swift升级到了1.2。 Swift 1.2 uses as! Swift 1.2用作! to represent forced conversions. 代表强制转换。 The statement will fail if you downcast to an invalid type. 如果您向下转换为无效类型,则该语句将失败。

It's simple though .. you just have to use as! 这很简单..您只需要使用as! instead of as. 而不是as。 One of my apps did not work properly with the conversion tool so I did have to go through and update them manually. 我的一个应用程序无法与转换工具一起正常使用,因此我必须手动检查并更新它们。 It's a pain, but it's a one-off and shouldn't take you more than an hour. 这很痛苦,但这是一次性的,不应该花你一个多小时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM