2

I've got the following error:

enter image description here

with Xcode-beta 5 and Swift. In beta 4 it works fine. Anybody who can help me?

extension UIImageView { public func imageFromUrl(_ urlString: String) { if let url = URL(string: urlString) { let request = URLRequest(url: url) NSURLConnection.sendAsynchronousRequest(request, queue: OperationQueue.main) { (response: URLResponse?, data: Data?, error: NSError?) -> Void in self.image = UIImage(data: data!) } } } } 
1
  • 2
    The change from NSError to Error is documented in the beta 5 release notes. Commented Aug 10, 2016 at 18:12

1 Answer 1

4

Read the error. Look as the type of your error parameter. You've declared it as NSError but the error message is telling you that it should be declared as Error, not NSError.

So you code should be:

extension UIImageView { public func imageFromUrl(_ urlString: String) { if let url = URL(string: urlString) { let request = URLRequest(url: url) NSURLConnection.sendAsynchronousRequest(request, queue: OperationQueue.main) { (response: URLResponse?, data: Data?, error: Error?) -> Void in self.image = UIImage(data: data!) } } } } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.