您的位置:首页 > 移动开发 > Swift

Swift 踩坑

2015-12-04 09:12 429 查看
Swift 的学习势在必行

苹果官方文档上也提到过,Swift语言将会取代Objective-C

我们要加快学习Swift的步伐

在学习Swift 过程中会遇到很多坑 但是也会从中学到不少知识

我们要有一种踩坑的精神

下面给大家讲一个

import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let incrementorByTen = makeIncrementor(forIncrement: 10)

print(incrementorByTen())

// Do any additional setup after loading the view, typically from a nib.
}

func makeIncrementor(forIncrement amount: Int) -> () ->Int {
var runningTotal = 0
func incrementor() -> Int {
runningTotal += amount
return runningTotal
}
return incrementor
}

}
代码不长 运行时会报这样的错误 :



确实有解决方案: 但是没有什么用 问题一样 但是没有解决 查找了好多资料

顺便多说一句查找资料上这个网站:http://stackoverflow.com/questions/19068715/command-applications-xcode-app-contents-developer-toolchains-xcodedefault-xctoo

全世界的大神都在上面 没有解决不了的问题 也算是送大家一点干货 哈哈



继续解决

结果发现 犯了一个很不容易发现的错误

工程名起得是-----> Swift

与库文件名字冲突了,更正过之后,运行成功 确实有点坑

代码以后会讲,今天这个坑大家要记住
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: