“PFObject"没有名为“下标"的成员 [英] 'PFObject' does not have a member named 'subscript'

查看:17
本文介绍了“PFObject"没有名为“下标"的成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我明白,这个特定的错误已经在这里和那里发布了,代码有点基础,但我自己仍然无法弄清楚这个错误 &我需要建议.

I understand, this particular error was already posted here and there and the code is somewhat basic, but I myself still unable to figure this one out & I need advice.

问题是当我添加 parse.com 上提供的用于保存对象的 代码的前两行时

The thing is when I add the first two lines of code provided on parse.com for saving objects

var gameScore = PFObject(className:"GameScore")
gameScore["score"] = 1337

第二行出现以下错误:

'PFObject' 没有名为 'subscript' 的成员

'PFObject' does not have a member named 'subscript'

我使用的是 Xcode 6.3 beta 2.所有必需的库都与二进制链接, 通过 BridgeHeader 导入.

I'm on Xcode 6.3 beta 2. All required libraries are linked with binary, <Parse/Parse.h> imported via BridgeHeader.

我应该使用什么语法?

推荐答案

这是由于 1.6.4 版本的 parse sdk 将 Objective-C Nullability Annotations 添加到框架所致.特别是文件 Parse/PFObject.h 定义:

This is happening due to the 1.6.4 version of the parse sdk which added Objective-C Nullability Annotations to the framework. In particular the file Parse/PFObject.h defines:

- (PF_NULLABLE_S id)objectForKeyedSubscript:(NSString *)key;

这是导致 Swift 编译错误的原因.删除 PF_NULLABLE_S 可以解决问题.

which is causing the Swift compile error. Removing the PF_NULLABLE_S fixes the problem.

另一方面,键控下标的对象可能是 nil 似乎是正确的,所以我怀疑这是一个 Swift 错误......

On the other hand it seems correct that an object for a keyed subscript might be nil, so I suspect this is a Swift bug...

这篇关于“PFObject"没有名为“下标"的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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