不兼容的指针类型将'Class'发送到'id <UIActionSheetDelegate>'类型的参数

Sim*_*iwi 13 warnings incompatibility ios

我收到警告不兼容的指针类型在下面的"delegate:self"行中将'Class'发送到'id'类型的参数:

    + (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;
Run Code Online (Sandbox Code Playgroud)

此警告在ShareKit中,如果有人知道如何解决它,请告诉我!

Nik*_*nov 21

您正尝试在静态方法中传递self参数.这是不正确的,因为静态方法中没有此对象的特定实例.使它成为非静态方法或将此类的一些实例作为委托传递.


Cœu*_*œur 8

使用静态类时,您可以手动获取警告:

delegate:(id<UIActionSheetDelegate>)self
Run Code Online (Sandbox Code Playgroud)