0

メッセージ式の引数は、以下の太字の行に初期化されていない値であるという警告が表示されます。

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

何が間違っているのか、どうすれば修正できますか?PS-これはShareKitにあります

ありがとう!

編集1:それであなたはこれをするように言っているのですか?

+ (SHKActionSheet *)actionSheetForType:(SHKShareType)type
{
    SHKItem *myItem = [SHKItem text:@"Share"];  // See SHKItem for other convenience constructors for URL, image, text and file item types.
    SHKActionSheet *as = [SHKActionSheet actionSheetForItem:myItem];
    as.item.shareType = type;

    as.sharers = [NSMutableArray arrayWithCapacity:0];
    NSArray *favoriteSharers = [SHK favoriteSharersForType:type];

    // Add buttons for each favorite sharer
    id class;
    for(NSString *sharerId in favoriteSharers)
    {
        class = NSClassFromString(sharerId);
        if ([class canShare])
        {
            [as addButtonWithTitle: [class sharerTitle] ];
            [as.sharers addObject:sharerId];
        }
    }

    // Add More button
    [as addButtonWithTitle:SHKLocalizedString(@"More...")];

    // Add Cancel button
    [as addButtonWithTitle:SHKLocalizedString(@"Cancel")];
    as.cancelButtonIndex = as.numberOfButtons -1;

    return [as autorelease];
}

Edit2:

+ (SHKActionSheet *)actionSheetForType:(SHKShareType)type
{

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


    as.item.shareType = type;

    as.sharers = [NSMutableArray arrayWithCapacity:0];
    NSArray *favoriteSharers = [SHK favoriteSharersForType:type];

    // Add buttons for each favorite sharer
    id class;
    for(NSString *sharerId in favoriteSharers)
    {
        class = NSClassFromString(sharerId);
        if ([class canShare])
        {
            [as addButtonWithTitle: [class sharerTitle] ];
            [as.sharers addObject:sharerId];
        }
    }

    // Add More button
    [as addButtonWithTitle:SHKLocalizedString(@"More...")];

    // Add Cancel button
    [as addButtonWithTitle:SHKLocalizedString(@"Cancel")];
    as.cancelButtonIndex = as.numberOfButtons -1;

    return [as autorelease];
}
4

1 に答える 1

2

私は問題がこの行にあるとかなり確信しています:

delegate:as

問題は、デリゲートを「as」に設定していることです。これは、初期化中のアクションシートの名前です。(したがって、初期化中のオブジェクトに、その初期化子への引数としてrefを渡そうとしています)。

代わりに、alloc / init呼び出しでデリゲートをnilに設定し、呼び出し後にデリゲートを明示的に設定します。

SHKActionSheet *as = [[SHKActionSheet alloc] initWithTitle:SHKLocalizedString(@"Share")***
                                    delegate:nil
                                    cancelButtonTitle:nil
                                    destructiveButtonTitle:nil
                                    otherButtonTitles:nil];
as.delegate = as;
as.item = [[[SHKItem alloc] init] autorelease];
as.item.shareType = type;
于 2011-08-11T01:26:44.437 に答える