3

我已GDataframework在我的项目中添加,添加后,我收到错误“发现多个名为 'tag' 的方法结果不匹配”。如果我删除GDataFramework它工作正常。我可以修改GDataframework还是应该在我的项目中完成?

int buttonTag=[sender tag]  //here that error prompts up at every place in my project
4

3 回答 3

17

Is your code inside an action method, like this?

- (IBAction)buttonPressed:(id)sender {
    int buttonTag = [sender tag];
}

Then you can solve the problem by replacing id with the correct type of the sender (UIButton * in this case):

- (IBAction)buttonPressed:(UIButton *)sender {
    int buttonTag = [sender tag];
}

because the compiler then knows that sender is an instance of the UIButton class, and therefore knows which tag method is applied here.

Note that you can define the correct type already when creating the connection in Xcode:

enter image description here

于 2013-01-02T15:41:41.917 回答
0

在一种情况下,如果创建对象的工厂方法具有返回类型“id”,那么编译器将检查所有类中的方法签名。如果编译器在多个类中发现相同的方法签名,则会引发问题。因此,将返回类型“id”替换为“特定类名”。

于 2014-10-21T10:47:39.727 回答
0

此链接存在与您类似的问题:击败“找到多个名为 'xxx:' 的方法”错误尝试遵循该问题的答案在您自己的应用程序中所做的指南。

于 2012-12-25T07:11:48.320 回答