gpt4 book ai didi

swift - 解析 PFSubclassing 不适用于 Swift

转载 作者:搜寻专家 更新时间:2023-10-31 21:50:33 24 4
gpt4 key购买 nike

我已经复制了子类化的 Parse Swift 示例:

class Armor : PFObject, PFSubclassing {

override class func load() {
self.registerSubclass()
}
class func parseClassName() -> String! {
return "Armor"
}
}

我收到以下错误:

/Parse/Armor.swift:11:1: error: type 'Armor' does not conform to protocol 'PFSubclassing'
class Armor : PFObject, PFSubclassing {
^
__ObjC.PFSubclassing:15:28: note: protocol requires function 'object()' with type '() -> Self!'
@objc(object) class func object() -> Self!
^
__ObjC.PFSubclassing:23:52: note: protocol requires function 'objectWithoutDataWithObjectId' with type '(String!) -> Self!'
@objc(objectWithoutDataWithObjectId:) class func objectWithoutDataWithObjectId(objectId: String!) -> Self!
^
__ObjC.PFSubclassing:30:27: note: protocol requires function 'query()' with type '() -> PFQuery!'
@objc(query) class func query() -> PFQuery!
^
__ObjC.PFSubclassing:35:38: note: protocol requires function 'registerSubclass()' with type '() -> Void'
@objc(registerSubclass) class func registerSubclass()
^
/Parse/Armor.swift:14:9: error: 'Armor.Type' does not have a member named 'registerSubclass'
self.registerSubclass()
^ ~~~~~~~~~~~~~~~~

我看到了这个答案:https://stackoverflow.com/a/24899411/843151并尝试了该解决方案但没有成功,我得到了同样的错误。

关于为什么会发生这种情况有什么建议吗?提前致谢。

最佳答案

我需要在我的 Objective-C 桥接头文件中导入解析 PFObject+Subclass.h

#import <Parse/PFObject+Subclass.h>

关于swift - 解析 PFSubclassing 不适用于 Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25236760/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com