SDK analysis methods do not work in Xcode 6.3 Beta

So far, I have had problems with such blocks:

user.signUpInBackgroundWithBlock { (succeeded: Bool!, error: NSError!) -> Void in if error == nil { println("success") } else { println("\(error)"); // Show the errorString somewhere and let the user try again. } } 

When I add this to Xcode, I get the following:

 Cannot invoke 'signUpInBackgroundWithBlock' with an argument list of type '((Bool!, NSError!) -> Void)' 

When I run this code in Xcode 6.3 (not beta), it works fine. But in the beta, it fails and won't let me build. Any ideas if this will be clarified, or if there is another implementation that I could use. Ive tried to use only signUpInBackgroundWithTarget, but Im just could not correctly access the error if it was received.

+7
ios xcode
source share
5 answers

make sure you use the SDK version 1.7.1, and then removing types from your closure should do the trick:

 user.signUpInBackgroundWithBlock { (succeeded, error) -> Void in if error == nil { println("success") } else { println("\(error)"); // Show the errorString somewhere and let the user try again. } } 
+9
source share

With the new addition of Annotations for Nullability in Swift 1.2, you need to rewrite the code above like this (using Parse 1.7.1 +):

 user.signUpInBackgroundWithBlock { (succeeded: Bool, error: NSError?) -> Void in if let error = error { println(error) // there is an error, print it } else { if succeeded { println("success") } else { println("failed") } } } 

Now Parse now returns options (?) Instead of explicitly expanded objects (!).

+2
source share

Swift notation changed

 class AAPLList : NSObject, NSCoding, NSCopying { // ... func itemWithName(name: String!) -> AAPLListItem! func indexOfItem(item: AAPLListItem!) -> Int @NSCopying var name: String! { get set } @NSCopying var allItems: [AnyObject]! { get } // ... } 

After annotations:

 class AAPLList : NSObject, NSCoding, NSCopying { // ... func itemWithName(name: String) -> AAPLListItem? func indexOfItem(item: AAPLListItem) -> Int @NSCopying var name: String? { get set } @NSCopying var allItems: [AnyObject] { get } // ... } 

So you can change

(succeeded: Bool!, error: NSError!) -> Void in

to

(success: Bool, error: NSError?) -> Void in

+1
source share

What version of Parse SDK are you using? They released version 1.7.1 a few days ago, which should fix your problem.

0
source share

Edit:

 (succeeded: Bool!, error: NSError!) -> Void in 

to

 (succeeded, error) -> Void in 

This change is required due to changes in the Parse SDK

0
source share

All Articles