Parse-sdk-ios-osx: Swift 3 support

Created on 16 Jun 2016  路  8Comments  路  Source: parse-community/Parse-SDK-iOS-OSX

Will you be updating SDK for Swift 3 compatibility?

Most helpful comment

@PeterKaminski09 Try to change to

PFCloud.callFunction(inBackground: "usernameValid", withParameters: ["username": username], block: { (object: Any?, error: Error?) in

// some your code

})

All 8 comments

From my understanding it shouldn't "need" it, being that the SDK is in Objective-C. I've successfully converted Parse projects to Swift 3 with no issues what-so-ever, with Xcode's built in migration tool. I guess if anything needs to be updated it would be the docs.

@dtalbert is absolutely right!
Since Parse SDK is written in ObjC, the transition to Swift 3 is seamless and should involve only your code.
Please open new issues if you experience any problems.

Hello,

I'm trying to migrate my app to swift 3, but when I'm looking at code modifications, XCode change call to SDK methods, for example,

Parse.initializeWithConfiguration(config);

become

Parse.initialize(with: config);

I think that I have to discard this type of change but I'm not really sure, Do you have a best practice to follow?

screen shot 2016-09-14 at 12 47 05 pm
After converting to Swift 3 all my cloud code gives this error.

@PeterKaminski09 Try to change to

PFCloud.callFunction(inBackground: "usernameValid", withParameters: ["username": username], block: { (object: Any?, error: Error?) in

// some your code

})

I'm completely stumped. Prior to swift 3 I had login and signup working now I can't figure out the Swift 3 syntax.

Also, just starting out, all the examples are with synchronous API + callback/blocks which is what I'm used to. But those are deprecated per the API docs?

https://github.com/ParsePlatform/docs/issues/378

Any help to get me up on my feet would be greatly appreciated.

@nitrag run it like this

PFCloud.callFunction(inBackground: "autoSave", withParameters: ["title": title], block: { (object: Any?, error: Error?) in

when i try to save(by calling object.save, or object.saveinBackground) i get the error below:

2017-06-14 05:00:48.442 ParseStarterProject-Swift[30427:2780933] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[1]' *** First throw call stack: ( 0 CoreFoundation 0x0000000103d27d4b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010378921e objc_exception_throw + 48 2 CoreFoundation 0x0000000103c37783 -[__NSPlaceholderArray initWithObjects:count:] + 275 3 CoreFoundation 0x0000000103c3e994 +[NSArray arrayWithObjects:count:] + 52 4 ParseStarterProject-Swift 0x000000010220af5d -[PFTaskQueue enqueue:] + 243 5 ParseStarterProject-Swift 0x00000001021b1e3f -[PFObject saveInBackground] + 121 6 ParseStarterProject-Swift 0x000000010217cded _TFC25ParseStarterProject_Swift14ViewController11viewDidLoadfT_T_ + 477 7 ParseStarterProject-Swift 0x000000010217cf52 _TToFC25ParseStarterProject_Swift14ViewController11viewDidLoadfT_T_ + 34 8 UIKit 0x00000001044d0a3d -[UIViewController loadViewIfRequired] + 1258 9 UIKit 0x00000001044d0e70 -[UIViewController view] + 27 10 UIKit 0x000000010439a4b5 -[UIWindow addRootViewControllerViewIfPossible] + 71 11 UIKit 0x000000010439ac06 -[UIWindow _setHidden:forced:] + 293 12 UIKit 0x00000001043ae519 -[UIWindow makeKeyAndVisible] + 42 13 UIKit 0x0000000104326f8d -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4818 14 UIKit 0x000000010432d0ed -[UIApplication _runWithMainScene:transitionContext:completion:] + 1731 15 UIKit 0x000000010432a26d -[UIApplication workspaceDidEndTransaction:] + 188 16 FrontBoardServices 0x000000010887e6cb __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24 17 FrontBoardServices 0x000000010887e544 -[FBSSerialQueue _performNext] + 189 18 FrontBoardServices 0x000000010887e8cd -[FBSSerialQueue _performNextFromRunLoopSource] + 45 19 CoreFoundation 0x0000000103ccc761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 20 CoreFoundation 0x0000000103cb198c __CFRunLoopDoSources0 + 556 21 CoreFoundation 0x0000000103cb0e76 __CFRunLoopRun + 918 22 CoreFoundation 0x0000000103cb0884 CFRunLoopRunSpecific + 420 23 UIKit 0x0000000104328aea -[UIApplication _run] + 434 24 UIKit 0x000000010432ec68 UIApplicationMain + 159 25 ParseStarterProject-Swift 0x000000010217dd6f main + 111 26 libdyld.dylib 0x000000010672868d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

any help?

Was this page helpful?
0 / 5 - 0 ratings