ios - TableCell init with coder and init with style -
i'm trying save custom cell objects , later on show them. fail understand mechanism totally have:
- (id)initwithcoder:(nscoder *)decoder { if((self = [super init])) { self.action = [decoder decodeobjectforkey:@"action"]; } return self; } and
- (id)initwithstyle:(uitableviewcellstyle)style reuseidentifier:(nsstring *)reuseidentifier { self = [super initwithstyle:style reuseidentifier:reuseidentifier]; if (self) { } return self; } this way variable decoded tablecell doesn't show @ all. if remove init coder tablecell interface showed, can't variable decoded. should make work?
i think can see problem. still, shouldnt save cells themselves. create uitableviewcell-subclass accepts 1 object gather of content. if need more 1 class this, thats fine too. can create several subclasses several usecases. save data-objects , recreate cells when need them again. reason way creates massive overhead, because trying save uiviews, lables, etc make cell. also, uitableviews highly optimized , try reuse existing cells not play approach.
tl;dr: need dataobjects, can save in keyedarchivers, , need tableviewcells accept these objects , display necessary data. seriously, save trouble. let me know if need , have fun
Comments
Post a Comment