我是Objective-C的新手,我正在尝试用这种方法创建一个已经有BeaconDemoMasterViewController类的代码:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
if (indexPath)
{
AppDelegate* delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[[segue destinationViewController] setDetailItem:[delegate notificationRegionAtIndex:indexPath.row]];
}
}
}
此方法在BeaconDemoDetailViewController类中调用其他方法:
- (void)setDetailItem:(id)newDetailItem
{
// Actualiza los valores si han cambiado
if (_detailItem != newDetailItem) {
_detailItem = newDetailItem;
// Actualiza la vista.
[self configureView];
}
}
它工作正常,但我需要在方法setDetailItem上有另一个参数。 我已经像这样修改了它们:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
if (indexPath)
{
AppDelegate* delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[[segue destinationViewController] setDetailItem:[delegate notificationRegionAtIndex:indexPath.row] Mallor:mayor];
}
}
}
'mayor'值已经为测试定义如下: NSString * mayor = @“1”;在课程开始时
并且在另一个类中,方法保持这样:
- (void)setDetailItem:(id)newDetailItem Mallor:(NSString *)mallor
{
mayor = mallor;
// Actualiza los valores si han cambiado
if (_detailItem != newDetailItem) {
_detailItem = newDetailItem;
// Actualiza la vista.
[self configureView];
}
}
然后我收到错误“没有已知的选择器实例方法'setDetailItem:Mallor:'”