简体   繁体   中英

Connecting aws ec2 Instance and Creating Object in Parse from Xcode?

So I'm setting up parse server in order to save user information in an app that I'm developing. The thing is, I've already created a keypair and accessed my appid, masterkey, and serverURL. I want to use this info to connect to parse server through Xcode inside AppDelegate.swift:

let parseConfiguration = ParseClientConfiguration(block: { (ParseMutableClientConfiguration) -> Void in
        ParseMutableClientConfiguration.applicationId = "appid"
        ParseMutableClientConfiguration.clientKey = "masterkey"
        ParseMutableClientConfiguration.server = "serverURL"

In Resources: Info.plist, I set App Transport Security Settings to Allow Arbitrary Loads. Over in ViewController.swift, I am trying to create an object and xcode show me that it has been saved. In addition I should be able to see that object saved in my parse dashboard:

import UIKit
import Parse

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    let testObject = PFObject(className: "TestObject2")

    testObject["foo"] = "bar"

    testObject.saveInBackground { (success, error) -> Void in
        print("Object has been saved.")

        // added test for success 11th July 2016

        if success {

            print("Object has been saved.")

        } else {

            if error != nil {

                print (error)

            } else {

                print ("Error")
            }

        }

    }

}

override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
    } 
}

When I run the code I don't see that the object has been saved in Xcode and nothing changes in parse either.

So I thought I'd retrace my steps and I noticed that my serverURL was rather simple compared to others:

http://52.38.256.24:80/parse

rather than:

http://52.38.256.24.us-west-2.compute.amazonaws.com:80/parse

So I went ahead and added what I saw everyone else online had but just to be sure, I tried to re-access my serverURL. I started out by opening terminal and entering in this:

Seifs-Mac-mini:~ Seif$ cd Downloads/
Seifs-Mac-mini:Downloads Seif$ chmod 400 Spotyr_Key_Pair.pem
Seifs-Mac-mini:Downloads Seif$ ssh -v -i "Spotyr_Key_Pair.pem" ubuntu@ec2-34-213-134-31.us-west-2.compute.amazonaws.com

Which resulted in several debug1 line ending in:

debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: Spotyr_Key_Pair.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

I've also tried

chmod 600 Spotyr_Key_Pair.pem

with no success.

At this point, Im really confused as to what the problem even is. Idk if I correctly connected the instance to begin with or if all that's irrelevant and the problem is in Xcode. I noticed a lot of people on SO having similar problems but I've tried everything that's helped them out with no success.

I've learned a lot trying to solve this problem but I'm still a novice. I apologize for the extremely long winded question, but I'm trying to save time for anyone who may attempt to answer with something I've already tried.

Any Suggestions will help.

Thanks in Advance!!!

调用testObject.saveInBackground后,错误变量的值是什么?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM