Incompatible pointer types sending 'Class' to parameter of type 'id<UIActionSheetDelegate>'

北城余情 提交于 2020-02-03 03:14:50

问题


I am receiving the warning Incompatible pointer types sending 'Class' to parameter of type 'id' in the line "delegate:self" below:

    + (SHKActionSheet *)actionSheetForType:(SHKShareType)type
{
    SHKActionSheet *as = [[SHKActionSheet alloc] initWithTitle:SHKLocalizedString(@"Share")
                                                      delegate:self
                                             cancelButtonTitle:nil
                                        destructiveButtonTitle:nil
                                             otherButtonTitles:nil];
    as.item = [[[SHKItem alloc] init] autorelease];
    as.item.shareType = type;

This warning is in ShareKit, if anyone knows how to fix it, please let me know!


回答1:


You are trying to pass self parameter in a static method. It is not right as there is no particular instance of this object in static methods. Make it either non static method or pass some instance of this class as delegate.




回答2:


When working with a static Class, you can manually get ride of the warning:

delegate:(id<UIActionSheetDelegate>)self



回答3:


Try using nil instead of self (xcode 4.2 iOS 5).



来源:https://stackoverflow.com/questions/6990783/incompatible-pointer-types-sending-class-to-parameter-of-type-iduiactionshee

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