iOS Parse PFObject Subclassing with Swift Behaviour

时光怂恿深爱的人放手 提交于 2019-12-04 06:30:13

问题


I have a strange issue, my subclassing works in all my view controllers except one.

I have imported everything that is required, but this one class is giving me the

"Missing argument for parameter 'className' in call"

My subclass

import Foundation
import Parse

class Session : PFObject, PFSubclassing {

    class func parseClassName() -> String {
        return "Session"
    }

}

// i have removed the non important info

I perform the

Session.registerSubclass()

In the app delegate

In EVERY class I have i can create a session via

var se = Session()

But in this one class, this will not work.

The class

import UIKit
import Parse

class PurchaseViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        var se = Session()
        // gives me an the above error
    }

}

I've tried deleting the class, creating a new one even with a new name - still does not work.

MORE INFO

Ok... something made me try removing some local class Vars from the classes where the object creation works, I found that by removing

let currentUser = PFUser.currentUser()! as! FighterUser

// This is my subclassed PFUser object

Causes that class to throw there error, and adding this var into the ViewController that was not working before stops the error

Any logic to how / why this occurs? A bug ?

This works

import Parse
import UIKit

class PurchaseViewController: UIViewController {

let currentUser = PFUser.currentUser()! as! FighterUser

override func viewDidLoad() {
    super.viewDidLoad()

    var se = Session()

}

More Info 2

Even just adding

let currentUser = PFUser.currentUser()

Removes the error


回答1:


Yup, it's a bug that will be addressed in 1.7.3 https://developers.facebook.com/bugs/1647055045527392/



来源:https://stackoverflow.com/questions/30158193/ios-parse-pfobject-subclassing-with-swift-behaviour

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!