使用 Swift 行为的 iOS Parse PFObject 子类化 [英] iOS Parse PFObject Subclassing with Swift Behaviour

查看:28
本文介绍了使用 Swift 行为的 iOS Parse PFObject 子类化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题,我的子类化在除一个之外的所有视图控制器中都有效.

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()

在应用委托中

在我有的每一堂课中,我都可以通过

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

导致该类抛出错误,并将此变量添加到在停止错误之前不起作用的 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/

这篇关于使用 Swift 行为的 iOS Parse PFObject 子类化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆