小编Mit*_*son的帖子

Xcode 6 Swift代码完成无法正常工作

使用Xcode 6 GM种子我的代码完成已停止工作.它前几天正在工作.我试图让unwindwind segue工作.我制作了一个Objc头文件,并将其指定为Swift类的头文件.

此时,我使用Objective-c项目完成代码.但是,不是Swift项目.

我尝试重新启动Xcode,制作一个新的空项目.

xcode objective-c swift

59
推荐指数
5
解决办法
2万
查看次数

Swift 2 Array包含对象?

为什么这不起作用?我可以在String上使用array.contains()但它不适用于Object.

var array = ["A", "B", "C"]

array.contains("A") // True

class Dog {
    var age = 1
}

var dogs = [Dog(), Dog(), Dog()]
var sparky = Dog()
dogs.contains(sparky) // Error Cannot convert value of type 'Dog' to expected argument type '@noescape (Dog) throws -> Bool
Run Code Online (Sandbox Code Playgroud)

arrays contains swift

10
推荐指数
2
解决办法
1万
查看次数

从UIAlertAction获取UIAlertController吗?

我想调用一个函数,而不是使用带有UIAlertAction的闭包。是否可以获取对拥有UIAlertAction的UIAlertController的引用?

alert = UIAlertController(title: "City", message: "Enter a city name", preferredStyle: UIAlertControllerStyle.Alert)
UIAlertActionStyle.Default, handler: okAlert)

//...

func okAlert(action: UIAlertAction) {
    // Get to alert here from action?
}
Run Code Online (Sandbox Code Playgroud)

swift uialertcontroller uialertaction

2
推荐指数
1
解决办法
2042
查看次数