-6

Given a piece of code like this:

func downloadImage() {
    // if image is not downloaded yet, get it
    // 1
    if (post?.image.value == nil) {
        // 2
        post?.imageFile!.getDataInBackgroundWithBlock { (data: NSData?, error: NSError?) -> Void in

            if let data = data {

                let image = UIImage(data: data, scale:1.0)!
                // 3
                self.post!.image.value = image
            }
        }
    }
}

What is the difference if I turned post from ? to !

Also, how come when I try and do ! I get a:

EXC_BAD_INSTRUCTION, but when I use ? I do not get the error but the screen I am trying to load does not load till a refresh?

Ideas?

1 Answers1

0

dispatch_async(dispatch_get_main_queue()) { \ update UI code }

  • Is this an answer or an attempted edit to the question? Either explain what this code does or edit the question instead. – JJJ Jan 09 '17 at 10:40
  • @JJJ: looks like they copied [this comment](https://stackoverflow.com/questions/38650152/what-is-the-difference-between-question-mark-and-exclamation-point-in-swift/38650353#comment64682762_38650152), to which they responded with *awesome works great, thank you*. Presumably this is some kind of answer. – Martijn Pieters Jan 09 '17 at 10:41