iOS使用Swift行为解析PFObject子类 [英] iOS Parse PFObject Subclassing with Swift Behaviour
问题描述
我有一个奇怪的问题,我的子类可以在我的所有视图控制器中工作,除了一个。
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
调用中参数'className'缺少参数
"Missing argument for parameter 'className' in call"
我的子类
import Foundation
import Parse
class Session : PFObject, PFSubclassing {
class func parseClassName() -> String {
return "Session"
}
}
//我删除了非重要信息
// i have removed the non important info
我执行
Session.registerSubclass()
在app delegate中
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.
班级
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.
更多信息
好的......做的东西我尝试从对象创建工作的类中删除一些本地类Vars,我发现通过删除
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
//这是我的子类PFUser对象
// This is my subclassed PFUser object
导致该类抛出错误,并将此var添加到之前无效的ViewController中停止错误
Causes that class to throw there error, and adding this var into the ViewController that was not working before stops the error
任何关于如何/为什么的逻辑这会发生吗?一个错误?
这是有效的
import Parse
import UIKit
class PurchaseViewController: UIViewController {
let currentUser = PFUser.currentUser()! as! FighterUser
override func viewDidLoad() {
super.viewDidLoad()
var se = Session()
}
更多信息2
即使只是添加
let currentUser = PFUser.currentUser()
删除错误
推荐答案
是的,这是一个错误请参阅1.7.3 https://developers.facebook.com/bugs/1647055045527392/
Yup, it's a bug that will be addressed in 1.7.3 https://developers.facebook.com/bugs/1647055045527392/
这篇关于iOS使用Swift行为解析PFObject子类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!