Mfck
Mfck

Reputation: 45

issue when invoking findObjectsInBackGroundWithBlock() with Parse in iOS

Using Parse in my project, i have this line

query.findObjectsInBackgroundWithBlock({ (objects:[PFObject], error:NSError) -> Void in      })

But Xcode keeps telling me :

cannot invoke this method with an argument list `([PFObject],NSError)`.

Any idea why??

Upvotes: 1

Views: 1219

Answers (2)

Alex Santarelli
Alex Santarelli

Reputation: 26

Instead of at the end of each parameter having an exclamation point at the end of it, change the ! to a ? So it would be

query.findObjectsInBackgroundWithBlock({ (objects: [AnyObject]?, error: NSError?) -> Void in

That was what I tried and it seemed to work.

Upvotes: 1

Antonio
Antonio

Reputation: 72820

The 2 closure parameters are both optionals, declared as implicitly unwrapped:

query.findObjectsInBackgroundWithBlock({ (objects: [AnyObject]!, error: NSError!) -> Void in
                                                              ^                ^

Also, I think that the first argument should be [AnyObject]! and not [PFObject]! - not sure, so I suggest you to verify that.

Upvotes: 0

Related Questions