1
我想創建自定義PFObject類,但它給了我一個非常令人困惑的錯誤「物業self.photo在super.init調用未初始化」子PFObject和覆蓋初始化
這裏是我的自定義類的代碼:
import Foundation
import Parse
class Wish: PFObject, PFSubclassing {
var id: String?
var name: String?
var descriptionWish: String?
var photo: UIImage
var photoThumbnail: UIImage
var amount: Double?
var amountDonated: Int?
static func parseClassName() -> String {
return "Wish"
}
override init() {
super.init()
}
convenience init(id: String?, name: String?, descriptionWish: String?, photo: UIImage, photoThumbnail: UIImage, amount: Double?, amountDonated: Int?) {
self.init()
self.id = id
self.name = name
self.descriptionWish = descriptionWish
self.photo = photo
self.photoThumbnail = photoThumbnail
self.amount = amount
self.amountDonated = amountDonated
}
}
任何想法如何使這個類的自定義初始值設定項? 我想打電話給我的願望類是這樣的:
Wish(id: "123", name: "xxx", descriptionWish: "Lorem ipsum", photo: photoImage, photoThumbnail: photoImageThumbnail, amount: 22.20, amountDonated: 10)
和投PFObject這樣
let wish = myPfObject as Wish
任何幫助表示讚賞!
謝謝,很好的回答! –