Why am I am getting the warning “Multiple methods named 'center' found”

隐身守侯 提交于 2019-12-12 04:14:05

问题


I only get this warning if I import my helper class (#import "JLHelper.h").

An example of the where the warning occurs...

[[subViews objectAtIndex:i] center].y+translation.y)];

I understand that it is telling me that the compiler sees more than one method named center, but center is declared in the framework in CLRegion.h.

Why would the compiler see more than one method in this case? Is it a problem to be concerned about, and if so how do I track down and resolve it.

Thanks,

John

Problem solved, thanks to Eric! Here is a more extensive look at my code after it was fixed

NSArray *subViews = [self subviews];
UIImageView *bottomResizer;
int count = [subViews count];
for (int i =count-1; i>=0; i--) {
    if([[subViews objectAtIndex:i] tag] == 301) {
        bottomResizer = (UIImageView*)[subViews objectAtIndex:i];
        [bottomResizer setCenter:CGPointMake([bottomResizer center].x, [bottomResizer center].y+translation.y)];

    }
}

回答1:


Looks like you need to cast the object so it knows what center you mean...

[((OBJECT_TYPE*)[subViews objectAtIndex:i]) center].y+translation.y)];

Where OBJECT_TYPE is a CLRegion Object



来源:https://stackoverflow.com/questions/11129778/why-am-i-am-getting-the-warning-multiple-methods-named-center-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!