代码之家  ›  专栏  ›  技术社区  ›  GuiDupas

Parse PFUser未注册子类

  •  0
  • GuiDupas  · 技术社区  · 8 年前

    Failed to set (contentViewController) user defined inspected property on (NSWindow): The class PFUser must be registered with registerSubclass before using Parse.

    它在未注册类的情况下发生。

    PFUser.registerSubclass() 但它仍然不起作用。

    我将使用默认的PFUser,而不向其添加任何字段,因此我不需要创建自定义类作为我的PFUser。

    我试着使用 PFUser.enableAutomaticUser()

    代码如下:

    import Cocoa
    
    import Parse
    import Bolts
    
    @NSApplicationMain
    class AppDelegate: NSObject, NSApplicationDelegate {
    
        let APP_ID = "app_id"
        let CLIENT_KEY = "client_key"
        let SERVER = "https://parseserver.com/"
    
        func applicationDidFinishLaunching(_ aNotification: Notification) {
    
            PFUser.registerSubclass()
    
            let configuracaoParse = ParseClientConfiguration {
                $0.applicationId = self.APP_ID
                $0.clientKey = self.CLIENT_KEY
                $0.server = self.SERVER
            }
    
            Parse.initialize(with: configuracaoParse)
        }
    
        func applicationWillTerminate(_ aNotification: Notification) {
            // Insert code here to tear down your application
        }
    }
    

    import Cocoa
    
    import Parse
    
    class ViewController: NSViewController {
    
        @IBOutlet weak var emailTextField: NSTextField!
        @IBOutlet weak var senhaSecureTextField: NSSecureTextField!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            contaUsuarios()
        }
    
        override var representedObject: Any? {
            didSet {
            // Update the view, if already loaded.
            }
        }
    
        @IBAction func entrarButtonClicked(_ sender: NSButton) {
    
        }
    
        func contaUsuarios() {
    
            let query = PFUser.query()
    
            query?.countObjectsInBackground(block: {
                (count, error) -> Void in
    
                let numeroUsers = Int(UInt32(count))
    
                if numeroUsers > 0 {
    
                }
    
                print(numeroUsers)
            })
        }
    }
    
    1 回复  |  直到 8 年前
        1
  •  0
  •   GuiDupas    8 年前

    在阅读互联网上的一些内容时,我发现在OSX中,ViewController是在AppDelegate完成加载之前启动的,因此我在中初始化了解析连接和子类化 ViewController's viewDidLoad 而不是AppDelegate,它工作得很好。

    推荐文章