swift - Parse PFUser not registering subclass -
i trying use parse pfuser in software osx desktop. when try use pfuser.query() gives message: failed set (contentviewcontroller) user defined inspected property on (nswindow): class pfuser must registered registersubclass before using parse.
it happening without registering class.
i tried registering class way: pfuser.registersubclass() still doesn't work.
i use default pfuser without adding fields it, don't need create custom class pfuser.
i tried use pfuser.enableautomaticuser() without success
code below:
appdelegate.swift
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 tear down application } } viewcontroller.swift
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 view, if 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) }) } }
reading content on internet discovered in osx viewcontroller launched before appdelegate finishes loading, initialized parse connection , subclassing in viewcontroller's viewdidload instead of appdelegate , working fine.
Comments
Post a Comment