objective c - How to call default insertNewObject method in IOS -
how can call default insertnewobject method? have created custom button in storyboard , linked action called adddate, don't quite understand parameter insertnewobject takes in
- (void)insertnewobject:(id)sender { if (!_objects) { _objects = [[nsmutablearray alloc] init]; } [_objects insertobject:[nsdate date] atindex:0]; nsindexpath *indexpath = [nsindexpath indexpathforrow:0 insection:0]; [self.tableview insertrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationautomatic]; } - (ibaction)adddate:(id)sender { // have call insertnewobject }
(id)sender parameter refers uiview calling method, uibutton if don't need parameters on function, delete :(id)sender , call
[self insertnewobject]; if need parameter, nsstring, substitute :(id)sender :(nsstring)parameter or whatever type of parameter want, , call
[self insertnewobject:yourparameter];
Comments
Post a Comment