Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
262 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 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...