13

我在下面的“delegate:self”行中收到警告不兼容的指针类型将“类”发送到“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;

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

4

3 回答 3

21

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

于 2011-08-09T02:29:21.313 回答
9

使用静态类时,您可以手动解除警告:

delegate:(id<UIActionSheetDelegate>)self
于 2013-08-19T14:06:54.537 回答
3

尝试使用 nil 而不是 self (xcode 4.2 iOS 5)。

于 2011-11-03T19:03:49.630 回答