有什麼東西適合存 app 關掉也還會存在的一堆陣列?

29 views
Skip to first unread message

hSATAC

unread,
Jul 16, 2012, 12:13:13 AM7/16/12
to cocoah...@googlegroups.com
All,
我想設計一個 download / upload 功能
他會有一個 queue 可以依序執行傳輸
即使 view 被 pop 掉還是會在背景執行傳輸作業

想法是:
用 singleton 的方式來寫這個 viewcontroller
不過就我所知,view 被 pop 掉以後在低記憶體的狀況下還是有機會被 dealloc 掉
因此我想把 queue (應該是個 NSMutableArray) 存在一個就算 view 被 dealloc 掉,甚至 app crash, closed
下次這個 view 被 init 出來以後還是能把沒傳完的 queue 抓回來繼續傳

請問有什麼地方適合存這個 queue 的 array?
1. 想辦法弄在 app delegate 上?
2. NSDefault ?
3. CoreData ?

還是有其他作法?
謝謝。

Evadne Wu

unread,
Jul 16, 2012, 12:15:42 AM7/16/12
to cocoah...@googlegroups.com
AFNetworking
--
您已訂閱「Google 網上論壇」的「cocoaheads.tw」群組,因此我們特別傳送這封郵件通知您。
如要在網路上查看這項討論,請造訪 https://groups.google.com/d/msg/cocoaheadstw/-/TH5teJWIVYQJ
如要在此群組張貼留言,請傳送電子郵件至 cocoah...@googlegroups.com
如要取消訂閱此群組,請傳送電子郵件至 cocoaheadstw...@googlegroups.com
如需更多選項,請造訪此群組:http://groups.google.com/group/cocoaheadstw?hl=zh-TW

Weizhong Yang

unread,
Jul 16, 2012, 12:28:34 AM7/16/12
to cocoah...@googlegroups.com
簡單的寫法是把 view controller 與下載進度的 model 拆開。

下載進度的 model 寫成一個 singleton 物件。

負責顯示下載進度的 view controller 則是這個 model 的 delegate。


cAt

unread,
Jul 16, 2012, 12:59:04 AM7/16/12
to cocoah...@googlegroups.com
@zonble 謝謝,我是打算用這樣的寫法
不過要讓 app 關掉以後 queue 不會消失,
這個 queue array 要存在什麼地方比較適合?
謝謝

jamie :~)

unread,
Jul 16, 2012, 2:02:51 AM7/16/12
to cocoah...@googlegroups.com
Go for CoreData. In the end, it pays back all the efforts.

hSATAC於 2012年7月16日星期一UTC+8下午12時59分04秒寫道:

Evadne Wu

unread,
Jul 16, 2012, 2:33:03 AM7/16/12
to cocoah...@googlegroups.com
RestKit, in that regard.

Eve
> --
> 您已訂閱「Google 網上論壇」的「cocoaheads.tw」群組,因此我們特別傳送這封郵件通知您。
> 如要在網路上查看這項討論,請造訪 https://groups.google.com/d/msg/cocoaheadstw/-/VMb7hvjBaFwJ

"Felix Chern (陳仁乾)"

unread,
Jul 16, 2012, 1:26:10 AM7/16/12
to cocoah...@googlegroups.com
存在NSUserDefaults
--
Felix Ren-Chyan Chern 陳仁乾
Research Assistant
Institute of Information Science
128 Academia Road, Section 2, Nankang,
Taipei 115, Taiwan, R.O.C.
Tel: 886-2-2788-3799 Ext.1456
Fax: 886-2-2651-8660

Reply all
Reply to author
Forward
0 new messages