Getting error in Xcode when doing this if let objects = objects as? [PFObject]

denislexic

Just upgraded to Swift 2 and using Xcode 7. Using Parse for backend.

I'm doing a normal query in background:

let query = PFQuery(className: "User")
query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in

    if let objects = objects as? [PFObject] {

    }
}

I get error in Xcode:

Downcast from '[PFObject]?' to '[PFObject]' only unwraps optionals; did you mean to use '!'?

Any ideas how I can fix this?

Arturo Jamaica

Just remove as? [PFObject]

Parse Change the [AnyObject] to a [PFObject]

findObjectsInBackgroundWithBlock({(objects:[AnyObject]?, error:NSError?)

so :

findObjectsInBackgroundWithBlock { (objects, error)

The Downcast is not required

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Getting Dagger to inject mock objects when doing Espresso functional testing for Android

From Dev

Error when doing linear regression using zoo objects ... Error in `$<-.zoo`(`*tmp*`

From Dev

Error when doing linear regression using zoo objects ... Error in `$<-.zoo`(`*tmp*`

From Dev

What am I doing wrong when combining objects with the module pattern

From Dev

What am I doing wrong when combining objects with the module pattern

From Dev

Getting "(undefined local variable or method" error when tryihng to create a form to update multiple objects

From Dev

Why am I getting a fatal error when trying to get the diff() of 2 DateTime Objects

From Dev

Getting error when trying to create array of json-objects in Rails 4 with PostgreSQL

From Dev

Type Error when Accessing and returning objects arrays inside objects

From Dev

Getting this error when I am doing npm start

From Dev

How to hide tablix in ssrs? getting error message when doing preview

From Dev

Getting 500 ERROR when doing an AJAX request in Laravel

From Dev

getting an error: relink message when doing a make install for openldap

From Dev

what is a for loop doing on file objects?

From Dev

Delete Objects From Parse/ Cannot cast to PFObject/ NSArrayM

From Dev

Object Required Error when referencing Excel Objects

From Dev

Core Data: Error when deleting/adding objects

From Dev

C++ Unexpected error when deleting objects

From Dev

Error when unarchiving objects from iCloud file

From Dev

Error when creating array of objects in a javascript loop

From Dev

WCF error when querying using LINQ to Objects

From Dev

Error When Comparing Objects of Type Double?

From Dev

Core Data: Error when deleting/adding objects

From Dev

Error when copy paste on excel using objects

From Dev

Error when initializing vector of objects with size

From Dev

Overload error when adding objects to list

From Dev

Javascript: Weird error when working with JS Objects

From Dev

Should objects be declared const or let?

From Dev

getting "fatal error: NSArray element failed to match the Swift Array Element type" when trying to read values from an array of class objects

Related Related

  1. 1

    Getting Dagger to inject mock objects when doing Espresso functional testing for Android

  2. 2

    Error when doing linear regression using zoo objects ... Error in `$<-.zoo`(`*tmp*`

  3. 3

    Error when doing linear regression using zoo objects ... Error in `$<-.zoo`(`*tmp*`

  4. 4

    What am I doing wrong when combining objects with the module pattern

  5. 5

    What am I doing wrong when combining objects with the module pattern

  6. 6

    Getting "(undefined local variable or method" error when tryihng to create a form to update multiple objects

  7. 7

    Why am I getting a fatal error when trying to get the diff() of 2 DateTime Objects

  8. 8

    Getting error when trying to create array of json-objects in Rails 4 with PostgreSQL

  9. 9

    Type Error when Accessing and returning objects arrays inside objects

  10. 10

    Getting this error when I am doing npm start

  11. 11

    How to hide tablix in ssrs? getting error message when doing preview

  12. 12

    Getting 500 ERROR when doing an AJAX request in Laravel

  13. 13

    getting an error: relink message when doing a make install for openldap

  14. 14

    what is a for loop doing on file objects?

  15. 15

    Delete Objects From Parse/ Cannot cast to PFObject/ NSArrayM

  16. 16

    Object Required Error when referencing Excel Objects

  17. 17

    Core Data: Error when deleting/adding objects

  18. 18

    C++ Unexpected error when deleting objects

  19. 19

    Error when unarchiving objects from iCloud file

  20. 20

    Error when creating array of objects in a javascript loop

  21. 21

    WCF error when querying using LINQ to Objects

  22. 22

    Error When Comparing Objects of Type Double?

  23. 23

    Core Data: Error when deleting/adding objects

  24. 24

    Error when copy paste on excel using objects

  25. 25

    Error when initializing vector of objects with size

  26. 26

    Overload error when adding objects to list

  27. 27

    Javascript: Weird error when working with JS Objects

  28. 28

    Should objects be declared const or let?

  29. 29

    getting "fatal error: NSArray element failed to match the Swift Array Element type" when trying to read values from an array of class objects

HotTag

Archive