For me, I love to use Parse as the database for App. It’s more flexible than MySQL I think, and it has already had many api for us to use. In this article, I am going to illustrate how to use parse to implement signup and signin. 🙂 I use swift and Xcode to starting programming for my project.Basically, I will talk about these three sections:
Here is the parse website–Parse, after you sign in, you can create a new App in the dashboard.
Then hover your mouse to the app you have just created. Click Quickstart. Then click social->mobile->IOS->Swift, then if you have already got an existing project then choose the existing project, if not, choose new project. For the new project, you do not need to do any setup. So for here, I will illustrate how to setup with the existing project.
- Download & unzip the SDK
- Add the SDKS to your app.
You can just drag the Parse.framework and Bolts.framework you downloaded into your Xcode project folder target. Make sure the “Copy items to destination’s group folder” checkbox is checked. However, for me, I always drag all the framework into that.
There is one tip: If you create a new group and put all that framework into the new group, remember to change your framework path. If you do not do that, you can not import parse!
- Add the dependencies. Just click on targets -> Your app name -> and then the ‘Build phases’ tab. Expand ‘Link Binary with Libraries’ as shown. The libraries which need to be added have shown on the parse website.
Then connect your app to parse, do the same step like the website tutorial, I will not explain more about that. One thing still need to pay attention again is “import Parse”. If you come with an error called, no such module parse, the reason will be the path for the framework!
Then basic idea for this part is insert our user information to the database. Generally, in our Main.storyboard, we create some labels and textfields then we control drag that to our cocoa touch class. Here is an example code for register button action:
Inside this code, I have also created some validation for password and non-empty blankets. Remember, in parse, the password will be hidden to protect the user information. And the email has already have the validate check. So we do not need to write again.
Here is the code for login, the advantage for parse is that it has already got a logInWithUsernameInBackground. So that’s why I love it 🙂
Thanks for reading it. XD I learned this tips from my Group project, however, I cannot shared the source code of all my project now. 🙁 Maybe after the demo day of my project, I will publish that to gitHub. 🙂 If you have any questions, feel free to contact with me.XD