如何在IOS中调用默认insertNewObject方法

如何在IOS中调用默认insertNewObject方法,ios,objective-c,Ios,Objective C,如何调用默认的insertNewObject方法?我在故事板中创建了一个自定义按钮,并将其链接到一个名为addDate的操作,但我不太了解insertNewObject包含的参数 - (void)insertNewObject:(id)sender { if (!_objects) { _objects = [[NSMutableArray alloc] init]; } [_objects insertObject:[NSDate date] atIndex:0]; NSIndex

如何调用默认的insertNewObject方法?我在故事板中创建了一个自定义按钮,并将其链接到一个名为addDate的操作,但我不太了解insertNewObject包含的参数

- (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 to call insertNewObject
}
(id)sender
是一个参数,它引用调用该方法的
ui视图
,通常是
ui按钮
如果此函数不需要任何参数,只需删除
:(id)sender
并调用

[self insertNewObject];
如果您确实需要一个参数,比如说一个NSString,用
:(id)sender
替换
:(NSString)参数或您想要的任何类型的参数,然后调用

[self insertNewObject:yourParameter];
可能重复的