使用Swift開發(fā)iOS8 App實(shí)戰(zhàn)第七章的7-13編寫修改TODO,? ??@IBAction func Ok(sender: AnyObject) {?? ? ? ?? ? ? ? var image: String;? ? ? ? if childButton.selected {? ? ? ? ? ? image = "child-selected"? ? ? ? }else if phoneButton.selected {? ? ? ? ? ? image = "phone-selected"? ? ? ? }else if shoppingCartButton.selected {? ? ? ? ? ? image = "shopping-cart-selected"? ? ? ? }else{? ? ? ? ? ? image = "travel-selected"? ? ? ? }?? ?? ? ? ? if todo == nil{? ? ? ? ? ? let uuid = NSUUID().UUIDString? ? ? ? ? ? let todo = TodoModel(id: uuid, image: image, title: todoItem.text!, date: todoDate.date)? ? ? ? ? ? todos.append(todo)? ? ? ? }else{//? ? ? ? ? ? 為什么修改內(nèi)容時,并沒有將數(shù)據(jù)保存到todos數(shù)組而只是保存到了todo變量中,//? ? ? ? ? ? 而點(diǎn)擊確定返回后,頁面會更新為修改后的值呢?不理解!!!不理解!!!!!!!? ? ? ? ? ? todo?.image = image? ? ? ? ? ? todo?.title = todoItem.text!? ? ? ? ? ? todo?.date = todoDate.date? ? ? ? }? ? }點(diǎn)擊確定按鈕后,會進(jìn)行判斷,如果todo為空,頁面是新建頁面,所以將新增項(xiàng)加入到todos數(shù)組,然后頁面就可以更新了,但是如果不是點(diǎn)擊新建進(jìn)入的,那么頁面就是詳情頁,就可以進(jìn)行修改,但是只是將todo變量修改為當(dāng)前頁面值,并沒有更改todos數(shù)組值,為什么頁面也會更新成功啊??不明白求大神解釋下,謝謝!!!
1 回答

heiheipingguo
TA貢獻(xiàn)12條經(jīng)驗(yàn) 獲得超1個贊
你這說的有點(diǎn)模糊呀,如果詳情頁使用的是todo里的數(shù)據(jù)的話,你修改todo,詳情頁自然是會刷新數(shù)據(jù)的。你可以再把問題講的清楚一點(diǎn)
- 1 回答
- 0 關(guān)注
- 1318 瀏覽
添加回答
舉報
0/150
提交
取消