'PFObject'没有名为'下标'的成员 [英] 'PFObject' does not have a member named 'subscript'
问题描述
据我所知,这个特殊的错误已经在这里和那里发布了,而且代码有些基本,但我自己仍然无法想出这一个&我需要建议。
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上提供用于保存对象的代码
var gameScore = PFObject(className:"GameScore")
gameScore["score"] = 1337
我收到以下错误对于第二行:
I get the following error for the second line:
'PFObject'没有名为'subscript'的成员
'PFObject' does not have a member named 'subscript'
我在Xcode 6.3 beta 2上。
所有必需的库都与二进制文件链接,< Parse / Parse.h>
通过BridgeHeader导入。
I'm on Xcode 6.3 beta 2.
All required libraries are linked with binary, <Parse/Parse.h>
imported via BridgeHeader.
我应该使用什么语法?
推荐答案
这是因为解析sdk的1.6.4版本在框架中添加了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 bug ......
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屋!