Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
266 views
in Technique[技术] by (71.8m points)

ios - '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.

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

I get the following error for the second line:

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

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

What syntax should I use?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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;

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

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...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...