0

I'm doing a PFQuery to get uploaded file in column. How to get that file and if the column is null there's no file do something else ?

If the column is null i'm getting error message the query wont go well.

fatal error: unexpectedly found nil while unwrapping on Optional value

query.findObjectsInBackgroundWithBlock {
            (objects, error) -> Void in

            if error == nil
            {
                for object in objects! {
                    self.files.append(object.objectForKey("file") as! PFFile)     
                }

I want to get that file but if the column was null do something else ? how can i do that?

Salah
  • 933
  • 3
  • 13
  • 32

1 Answers1

0

Use optional unwrapping with if let file = ... as? PFFile {

} else {

}

Kristijan Delivuk
  • 1,253
  • 13
  • 24