0

I'm using Parse as the backend for my app. In the User Class I have a pointer to an Album Class. I am trying to store that Album pointer value in a variable. I've tried declaring the variable as a PFObject, but I get the following error:

unrecognized selector sent to class

Code looks like this

This variable is declared above the class so it's available globally

var album = PFObject()

func getUserInfo() {

        var currentUser = PFUser.currentUser()

        let userQuery = PFQuery(className: "_User")

        userQuery.whereKey("username", equalTo: PFUser.currentUser().username)
        userQuery.includeKey("album")

        userQuery.findObjectsInBackgroundWithBlock({ (results:[AnyObject]!, error:NSError!) -> Void in
            if error == nil {
                for result in results! {
                        album = result["album"] as PFObject
                }

            }
            }
        })
    }
1
  • What does your code look like? What line of code is causing that error to be thrown? When you fetch your user are you calling includeKey("Album") Commented Feb 27, 2015 at 2:33

2 Answers 2

1

Does the problem vanish if you declare your album as an album?:

var album = PFObject(className:"Album")

I think it's failing because it's trying to assign data coming in from the query to a plain old PFObject that lacks the right fields to hold the data.

Sign up to request clarification or add additional context in comments.

3 Comments

WooHoo...that solved it! Makes sense to me now. I'll learn this stuff some day. Thanks for the help.
You're welcome! (BTW, did you know "You're welcome!" seems to be the shortest thing you can type in a comment reply box?)
Good to know. Hopefully I'll be answering questions instead of asking them sometime soon. Thanks again.
0

When you fetch your user are you calling includeKey("Album")?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.