Achèvement rapide du bloc

Je vais avoir un moment difficile la compréhension d'un problème que je vais avoir.
Pour simplifier, je vais utiliser UIView méthode.
En gros, si j'écris la méthode

UIView.animateWithDuration(1, animations:  {() in
        }, completion:{(Bool)  in
            println("test")
    })

il fonctionne très bien.
Maintenant, si je fais la même méthode, mais la création d'une chaîne de caractères comme suit:

    UIView.animateWithDuration(1, animations:  {() in
        }, completion:{(Bool)  in
            String(23)
    })

Il s'arrête de fonctionner. Erreur de compilateur: argument Manquant pour le paramètre "retard" dans l'appel

Maintenant, voici la partie étrange. Si je n'ai exactement le même code que celui qui échoue, mais il suffit d'ajouter une commande d'impression comme suit:

   UIView.animateWithDuration(1, animations:  {() in
        }, completion:{(Bool)  in
            String(23)
            println("test")
    })

il commence à travailler à nouveau.

Mon problème est fondamentalement la même chose. Mon code:

   downloadImage(filePath, url: url) { () -> Void in
         self.delegate?.imageDownloader(self, posterPath: posterPath)
        }

Ne fonctionne pas. Mais si je change de.

 downloadImage(filePath, url: url) { () -> Void in
             self.delegate?.imageDownloader(self, posterPath: posterPath)
                println("test")
            }

ou encore:

downloadImage(filePath, url: url) { () -> Void in
             self.delegate?.imageDownloader(self, posterPath: posterPath)
             self.delegate?.imageDownloader(self, posterPath: posterPath)
            }

Il fonctionne très bien.
Je ne comprends pas pourquoi ce qui se passe. Je suis près à accepter que c'est un bug du compilateur.

OriginalL'auteur Wak | 2014-09-21