ios - self.property = self.property in objective c -
good morning, looking through old code online in objective c , having trouble finding out following means.
the class subclassing uiview , following uiscrollviewdelegate protocol. following class method have questions about:
@property(nonatomic, strong) nsdate * _nonnull date; - (void)layoutsubviews { [super layoutsubviews]; if(!self.pagingview) { uiscrollview *pagingview = [[uiscrollview alloc] initwithframe:self.bounds]; pagingview.pagingenabled = yes; pagingview.directionallockenabled = yes; pagingview.delegate = self; [pagingview setautoresizingmask:uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleheight]; [self addsubview:pagingview]; self.pagingview = pagingview; } cgrect f = self.pagingview.bounds; cgsize s = self.pagingview.contentsize; if(s.width != f.size.width * 3) { self.date = self.date; } } first, not sure [super layoutsubviews] achiving , not sure self.date = self.date trying do. setting itself? if so, not able work swift. (which trying convert code to)
https://github.com/daij-djan/ddcalendarview/blob/master/ddcalendarview_objc/ddcalendarview.m
thanks again help;
looking @ code posted, setdate: method performing view setup, doing self.date = self.date; author's way of forcing setup done without changing set date. better done if view setup code factored out of setdate:, make call setup after new date set. in above code, call setup method, updatedateviews or along lines.
as question code calling [super layoutsubviews];, idea time override method call superclass implementation, unless know sure superclass implementation , know don't need call it, , in rare cases don't want call it. rule of thumb add call superclass method. it's same when override viewwillappear:, viewwilldisappear:, etc. should calling superclass implementation those.
Comments
Post a Comment