Since you are initializing the data, the ["receipt-data" : recieptString! as AnyObject, "password" : IAPProduct.apiID.rawValue as AnyObject]
cannot be nil, and thus it makes no sense to wrap it in guard
. The only optional you have in this statement is recieptString
, which you are force-unwrapping (can be causing crash if recieptString!
is nil.
So change your guard statement to
guard let recieptString = receiptData?.base64EncodedString(options: NSData.Base64EncodingOptions(rawValue: 0)) else {
// ...
return
}
and then initialize the dictionary without guard or force unwrap:
let jsonDict: [String: AnyObject] = ["receipt-data" : recieptString as AnyObject, "password" : IAPProduct.apiID.rawValue as AnyObject]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…