I've followed this connect your swift application to Parse.com tutorial: http://ios-blog.co.uk/tutorials/connect-your-swift-application-to-parse-com/ and it worked great. This tutorial only shows you how to place data on the Parse.com service. So I did some research into how to retrieve data.
In the First tutorial it says to add data to Parse like so:
Parse.setApplicationId("your_application_key", clientKey: "your_client_key")
var object = PFObject(className: "testDataClass")
object.addObject("iOSBlog", forKey: "websiteUrl")
object.addObject("Five", forKey: "websiteRating")
object.save()
In the second tutorial, wrote by the Parse team (http://blog.parse.com/2014/06/06/building-apps-with-parse-and-swift/) It says to write it like this:
var gameScore = PFObject(className: "GameScore")
gameScore.setObject(1337, forKey: "score")
gameScore.setObject("Sean Plott", forKey: "playerName")
gameScore.saveInBackgroundWithBlock {
(success: Bool!, error: NSError!) -> Void in
if success {
NSLog("Object created with id: \(gameScore.objectId)")
} else {
NSLog("%@", error)
}
}
and then to retrieve it, use this code:
var query = PFQuery(className: "GameScore")
query.getObjectInBackgroundWithId(gameScore.objectId) {
(scoreAgain: PFObject!, error: NSError!) -> Void in
if !error {
NSLog("%@", scoreAgain.objectForKey("playerName") as NSString)
} else {
NSLog("%@", error)
}
}
However, When I use the Official Parse code I get the following error:
fatal error: Can't unwrap Optional.None
(lldb)
and All these things happen in almost every pane of Xcode:

Can someone tell me what is wrong and how to fix it? I am relatively new to Xcode and Swift so I would really appreciate a layman terms answer.
EDIT Here is the appDelegate.swift function
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
// Connect to Parse using the keys provided
Parse.setApplicationId("xxx", clientKey: "xxx")
// Store Data to Parse
var gameScore = PFObject(className: "GameScore")
gameScore.setObject(1337, forKey: "score")
gameScore.setObject("Sean Plott", forKey: "playerName")
gameScore.saveInBackgroundWithBlock {
(success: Bool!, error: NSError!) -> Void in
if success {
NSLog("Object created with id: \(gameScore.objectId)")
} else {
NSLog("%@", error)
}
}
var query = PFQuery(className: "GameScore")
query.getObjectInBackgroundWithId(gameScore.objectId) {
(scoreAgain: PFObject!, error: NSError!) -> Void in
if !error {
NSLog("%@", scoreAgain.objectForKey("playerName") as NSString)
} else {
NSLog("%@", error)
}
}
// Override point for customization after application launch.
return true
}
Much appreciated.
Added new code for user to see:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
// Connect to Parse using the keys provided
Parse.setApplicationId("xxxx", clientKey: "xxxx")
// Store Data to Parse
var gameScore = PFObject(className: "GameScore")
gameScore.setObject(1337, forKey: "score")
gameScore.setObject("Sean Plott", forKey: "playerName")
gameScore.saveInBackgroundWithBlock {
(success: Bool!, error: NSError!) -> Void in
if (success ?? false) {
NSLog("Object created with id: \(gameScore.objectId)")
} else {
NSLog("%@", error)
}
}
var query = PFQuery(className: "GameScore")
query.getObjectInBackgroundWithId(gameScore.objectId) {
(scoreAgain: PFObject!, error: NSError!) -> Void in
if error == nil {
NSLog("%@", scoreAgain.objectForKey("playerName") as NSString)
} else {
NSLog("%@", error)
}
}
// Override point for customization after application launch.
return true
}
NSLogoutput? Is your object created with an ID, or is an error printed? In any case, this sounds like it might be a Parse bug. If it can't find the object, I would assume it to execute the callback with anNSErrorinstance provided. - Craig Otisif !errorwithif error != nil. - vacawamascoreAgainactually have a value? Can you try comparing it tonilbefore using it? If not, I would suggest you change the method signature for the callback to:(scoreAgain: PFObject?, error: NSError?) -> Void, to force your code to check for a value. - Craig Otisif !errorwithif error == nil. - vacawama