小编Ren*_*ers的帖子

swift中带有可选闭包的参数

我正在使用可选的闭包,但无法找到传递参数的方法.到处搜索,尝试了所有的建议,但无法让它工作.

我的代码:

func DoAlert(title: String
    , message: String
    , actions: String
    , sender: AnyObject?
    , Ctlr : UIViewController
    , SegueString: String?
    , YesClosure: ()->() = {}
    , NoClosure: ()->() = {}
    , StartClosure: ()->() = {}
    , EndClosure: ()->() = {}
    ) {

if (actions.rangeOfString("Ok") != nil {
        alert.addAction(UIAlertAction(title: "OK", style: .Default ) { action -> Void in
            EndClosure()
            })}
} // end function
Run Code Online (Sandbox Code Playgroud)

我想为Ok添加一个闭包,其中需要'self'参数.

如下所示:

    // add to func doAlert: 
    , OkClosure: (AnyObject)->() = {}


            // add to action …
Run Code Online (Sandbox Code Playgroud)

parameters closures optional swift

6
推荐指数
1
解决办法
3936
查看次数

线程1:在IOS模拟器中更改硬件时,信号SIGTERM(快速)

我的Swift应用程式已针对特定的IOS装置设定,并在IOS模拟器中正常运作,

但是,当在IOS模拟器中更改硬件时,我在快速Thread1中收到错误:signal SIGTERM。

我可以为iOS设备iPhone 6设置swift,IOS模拟器可以运行iPhone 6,但是不能更改为其他硬件(例如iPhone 4S)。我可以为IOS设备iPhone 4S设置swift,并且IOS模拟器在iPhone 4S上可以正常运行,但是在更改硬件(例如之前运行良好的iPhone 6)时出现错误。

因此,我很确定快速的应用程序逻辑是正确的。

我该如何解决?

signals sigterm ios-simulator swift

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