【问题标题】:incompatible pointer types sending 'id' to parameter of type 'SEL_Notnull'不兼容的指针类型将“id”发送到“SEL_Notnull”类型的参数
【发布时间】:2017-05-10 09:49:12
【问题描述】:
[contactCell.no5 addTarget:self action:[self performSelector:@selector(numberEdit:cellIndex:) withObject:contactCell.no5 withObject:[NSNumber numberWithInteger:indexPath.row]] forControlEvents:UIControlEventValueChanged];

在contactCell.no5中“no5是文本字段”和“contactCell是uitableviewcell对象”...

  1. 不兼容的指针类型将“id”发送到“SEL_Notnull”类型的参数
  2. ARC 不允许将 Objective-C 指针隐式转换为“SEL_Notnull”

功能-->

-(void)numberEdit:(UITextField *)textField cellIndex:(NSNumber *)row
{    
    [numberList removeObjectAtIndex:[row integerValue]];
    NSLog(@"%@",numberList.description);

    [numberList insertObject:textField.text atIndex:[row integerValue]];
    NSLog(@"%@",numberList.description);
}

【问题讨论】:

  • 你得到了你的问题的解决方案......如果没有,你能解释你想做什么......为什么你会收到错误......@Pratik
  • 不,先生,我无法找到解决方案。我将 6 个文本字段放在 6 个不同的自定义单元格中。我想将该文本字段和该自定义单元格的索引路径从 cellForRowAtIndexPath 方法中出现的文本字段发送到 numberEdit:cellIndex: Method...@NAVEENKUMAR

标签: objective-c pointers casting automatic-ref-counting


【解决方案1】:

试试这个

如果你有这样的文本字段:

UITextField *contactCell;

你需要添加 targetLikeThis

 [contactCell addTarget:self action:@selector(numberEdit:cellIndex:) forControlEvents:UIControlEventValueChanged];

堡垒自定义动作:

-(void)numberEdit:(UITextField *)textField cellIndex:(NSNumber *)row
{    
    [numberList removeObjectAtIndex:[row integerValue]];
    NSLog(@"%@",numberList.description);

    [numberList insertObject:textField.text atIndex:[row integerValue]];
    NSLog(@"%@",numberList.description);
}

【讨论】:

  • 先生它不工作...... action 中存在错误..因为 action 接受 id 类型和选择器返回 SEL 类型...
猜你喜欢
  • 1970-01-01
  • 2012-09-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多