使用Swift開發(fā)iOS8 App實戰(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變量中,//? ? ? ? ? ? 而點擊確定返回后,頁面會更新為修改后的值呢?不理解!!!不理解!!!!!!!? ? ? ? ? ? todo?.image = image? ? ? ? ? ? todo?.title = todoItem.text!? ? ? ? ? ? todo?.date = todoDate.date? ? ? ? }? ? }點擊確定按鈕后,會進行判斷,如果todo為空,頁面是新建頁面,所以將新增項加入到todos數(shù)組,然后頁面就可以更新了,但是如果不是點擊新建進入的,那么頁面就是詳情頁,就可以進行修改,但是只是將todo變量修改為當前頁面值,并沒有更改todos數(shù)組值,為什么頁面也會更新成功啊??不明白求大神解釋下,謝謝!!!
1 回答

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