小编use*_*985的帖子

为什么我的DispatchGroup的等待总是超时?

我有这个代码:

let goAheadAction = UIAlertAction(title: "Go Ahead", style: .default) { _ in
    let dispatchGroup = DispatchGroup()
    dispatchGroup.enter()

    Server.POSTRequest(accessPoint: "/UserServices/forgotPassword", params:["emailAddress" : self.emailAddressTextField.text!], handler: {
            (data: Data?, response: URLResponse?, error: Error?) -> Void in
        // TODO: Only considered successful case
        /*let confirmAlertController = UIAlertController(title: "Email been sent", message: "Please check your mailbox", preferredStyle: UIAlertControllerStyle.alert)

        self.present(confirmAlertController, animated: true, completion: nil)*/

        dispatchGroup.leave()
    })

    let waitResult = dispatchGroup.wait(timeout: DispatchTime(uptimeNanoseconds: 10000000000))

    if waitResult == .success {
        let emailSentAlertController = UIAlertController(title: "Email Sent", message: "We've sent …
Run Code Online (Sandbox Code Playgroud)

multithreading grand-central-dispatch swift

7
推荐指数
1
解决办法
2647
查看次数

Haskell中函数组合的优先级是什么?

我在教科书上看到了这段代码:

double :: (Num a) => a -> a
double x = x * 2

map (double.double) [1,2,3,4]
Run Code Online (Sandbox Code Playgroud)

我没有得到的是,如果功能组合操作具有最高优先级,为什么要使用括号来包含double.double?如果我删除这些括号,我会收到错误消息.那么功能组合的优先级究竟是什么呢?

haskell

4
推荐指数
1
解决办法
297
查看次数