問題:
I'm new to iOS and Objective-C and the whole MVC paradigm and I'm stuck with the following:我是 iOS 和 Objective-C 以及整個MVC範式的新手,我堅持以下幾點:
I have a view that acts as a data entry form and I want to give the user the option to select multiple products.我有一個用作數據輸入表單的視圖,我想爲用戶提供選擇多個產品的選項。 The products are listed on another view with a UITableViewController
and I have enabled multiple selections.產品列在另一個帶有UITableViewController
視圖上,我啓用了多個選擇。
How do I transfer the data from one view to another?如何將數據從一個視圖傳輸到另一個視圖? I will be holding the selections on the UITableView
in an array, but how do I then pass that back to the previous data entry form view so it can be saved along with the other data to Core Data on submission of the form?我會將UITableView
上的選擇保存在一個數組中,但是我如何將其傳遞迴之前的數據輸入表單視圖,以便在提交表單時將其與其他數據一起保存到 Core Data?
I have surfed around and seen some people declare an array in the app delegate.我四處瀏覽,看到有些人在應用程序委託中聲明瞭一個數組。 I read something about singletons , but I don't understand what these are and I read something about creating a data model.我讀了一些關於singletons 的內容,但我不明白這些是什麼,我讀了一些關於創建數據模型的內容。
What would be the correct way of performing this and how would I go about it?執行此操作的正確方法是什麼,我將如何處理?
解決方案:
參考一: https://stackoom.com/question/LrUt參考二: Passing data between view controllers