cocoa - iOS design pattern to upload items to web while showing progress in a TableView -


i trying remove ui code dependency upload methods better understanding of mvc paradigms.

i want design way visualize upload progress inside uitableview, individual cells being designated show corresponding nsoperation subclasses. nsoperation subclass has been hacked support delegate callback pattern (ie non-concurrent/mainthread only). nsoperation looks this:

@class myuploadop; @protocol myuploaddelegate; -(void)uploadop:(myuploadop *)uploadop madeprogress:(cgfloat)progress; -(void)uploadop:(myuploadop *)uploadop diduploadlocalfile:(localfileobject *)localfile; @end  @interface myuploadop : nsoperation <dbrestclientdelegate> @property (nonatomic,strong) localfileobject *mylocalfile; -(id)initwithlocalfile:(localfileobject *)localfile; @end 

as can see, using dropbox sdk ios. nsoperation subclass uploads local file dropbox. receive necessary dropbox delegate methods inside nsoperation class , forward them onward class responsible setting , keeping track of upload.

what do, set new uitableviewcontroller, , custom uitableviewcells. don't need part, yadda yadda. need is:

  • keeping track of nsoperations may set up
  • assigning each nsoperation uitableviewcell
  • who should delegate of nsoperation receive these messages?
  • should instead set properties on operation, "progress" , use keyvalue observing?
  • if case, object should observing? cell or viewcontroller?
  • what happens when nsoperation finishes , disappears queue, need keep record around make sure table stays populated.
  • updating uiprogressbars in cells on every delegate method call
  • keeping items in table upon nsoperation completion

my current code working, don't have table stuff implemented yet. can't figure out best way keep track of these items. maybe need come nsobject subclass holds reference the operation, , fill table that?

keeping track of nsoperations may set up

add property operation can set identifier. then, when delegate methods called can read identifier , translate index path. in table view controller class, keep array of identifiers (the index in array row number it's displayed at).

assigning each nsoperation uitableviewcell

as described.

who should delegate of nsoperation receive these messages?

the table view controller.

should instead set properties on operation, "progress" , use keyvalue observing?

no, should cache progress value in array in table view controller if cells scrolled off screen can update them when scrolled on screen (without having go , find operation , query it).

what happens when nsoperation finishes , disappears queue, need keep record around make sure table stays populated.

that's fine, don't remove identifier array.

updating uiprogressbars in cells on every delegate method call

use contents of arrays stored in table view controller. 1 identifiers , 1 progress value. both arrays should have same number of items in them.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -