1 // 3.1 Determine if the agent implements the Protocol method 2 if ([Self. Delegate respondstoselector: @selector (Tgfooterviewdiddownloadbuttonclick:)]) {3 [self. Delegate Tgfooterviewdiddownloadbuttonclick:self]; 4 }
// If a proxy uses a strong reference, a circular reference is generated, causing the controller and child views to be freed, causing a memory leak IDdelegate;
1- (void) Tgfooterviewdiddownloadbuttonclick: (Hmtgfooterview *) Footerview2 {3 //get data load data on the simulated fetch network4NSLog (@"try to load data in ....");5 6Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (2.0* nsec_per_sec)), Dispatch_get_main_queue (), ^{7 //operations performed after obtaining network data8 9 //add data to the array to simulate the effect of the network after it is loadedTenNsdictionary *dict = @{@"title":@"haha",@"icon":@"ad_00",@" Price":@"100.2",@"Buycount":@" -"}; OneHmtg *TG =[Hmtg tgwithdict:dict]; A -NSLog (@"add data before%lu", (unsignedLong) self.tgs.count); - the [Self.tgs ADDOBJECT:TG]; - -NSLog (@"add data after%lu", (unsignedLong) self.tgs.count); - //Refresh Data + //[Self.tableview Reloaddata]; - //Create a new Indexpath +Nsindexpath *path = [Nsindexpath indexpathforrow: (Self.tgs.count-1) Insection:0]; A [Self.tableview Insertrowsatindexpaths:@[path] withrowanimation:uitableviewrowanimationmiddle]; at - //notifies the footer view to adjust the view display status - [Footerview Endrefresh]; - }); - -}
Determine if the agent implements the Protocol method