解析-使用Swift进行子类化? [英] Parse - Subclassing with Swift?

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

问题描述

我正在尝试获取一个标准的子类,以便快速使用.

I'm trying to get a standard subclassing to work with swift.

Bridging-Header.h

Bridging-Header.h

#import <Parse/Parse.h>
#import <Parse/PFObject+Subclass.h>
#import <Parse/PFGeoPoint.h>

子类

class Event: PFObject, PFSubclassing {

    class func parseClassName() -> String! {
        return "Event"
    }

    override class func load() {
        registerSubclass()
    }
}

得到一个编译错误,指出Event不符合PFSubclassing.

getting a compile error saying that Event does not conform to PFSubclassing.

有什么建议吗?

推荐答案

查看此线程.这是问题的解释:

Check out this thread. Here is an explanation of the problem:

关于这一点,我已经向Parse打开了一个错误.基本上,问题在于Parse头文件,其中PFSubclassing.h中的协议定义以这种方式定义此方法:+(instancetype)objectWithoutDataWithObjectId:(NSString)objectId;但是然后PFObject + Subclass.h通过这种方式实现相同的方法(注意区别:instancetype-> id)+(id)objectWithoutDataWithObjectId:(NSString)objectId;这足以让Swift抱怨.我发现的唯一解决方案是通过将"id"替换为"instancetype"来直接更改框架定义中的标头.如果执行此操作,则代码将编译.

所以,这是您的解决方案,对我有用.我遇到了同样的问题:

So, here's your solution, and it's worked for me; I had the same problem:

  • 打开PFSubclassing.h(请注意,这是您的Parse目录下的PFSubclassing.h)
  • 找到objectWithoutDataWithObjectId:方法
  • 将方法签名替换为:(id)objectWithoutDataWithObjectId:(NSString *)objectId;
  • Open PFSubclassing.h (note that this is the PFSubclassing.h under your Parse directory)
  • Find the objectWithoutDataWithObjectId: method
  • Replace the method signature with: (id)objectWithoutDataWithObjectId:(NSString *)objectId;

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

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