1
我即將在Swift 2.0應用程序中實現Realm模型。但是,一旦我安裝了Realm。我對我的應用程序AnyObject標會導致編譯錯誤帶AnyObject下標的Realm.io
不能與類型的索引「字符串」下標型「AnyObject」的值
無法下標類型「RLMProperty」的值與索引類型「字符串」的
從「RLMProperty」到「AnyObject」條件鑄總是成功
但事實是出口不應該擺在首位一個RLMProperty
以下是我的代碼
var campaigns = [AnyObject]()
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let campaignCell = tableView.dequeueReusableCellWithIdentifier("campaignCell", forIndexPath: indexPath) as! CampaignTableViewCell
let outlet: AnyObject = (self.campaigns[indexPath.section]["surveys"]!![indexPath.row])["outlet"]!!
// Configure the cell...
campaignCell.outletID.text = outlet["code"] as? String
campaignCell.outletNameLabel.text = outlet["name"] as? String
//campaignCell.outletAddressLabel.text = outlet["outlet"]!!["address"] as? String
campaignCell.outletStatusLabel.text = (self.campaigns[indexPath.section]["surveys"]!![indexPath.row])["progress"]!!["name"] as? String
campaignCell.outletStatusLabel.textColor = UIColor.colorWithHexString(((self.campaigns[indexPath.section]["surveys"]!![indexPath.row])["progress"]!!["color"] as? String)!)
return campaignCell
}
這個問題在Realm-Cocoa回購中也作爲[Github問題](https://github.com/realm/realm-cocoa/issues/2623)提出。 –
你能提供關於這個問題的更多信息嗎?哪些行與這些錯誤相關聯? –
我也在項目中看到同樣的錯誤。一旦我在項目的一個文件中導入了RealmSwift,它就出現了。除了導入語句之外,它不會引用Realm。 – angelo