3

ユーザーがUITableViewカスタム サウンドを選択できる があります。index.sectionユーザーが選択するものに基づいて、ロジックが組み込まれている IAP 用の 3 つの非消耗品があります。UIToolbarButtonロジックの変更 (IBActionユーザーが選択を保存できる別の場所がありますが、製品を「購入」した場合のみ):

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    // Pull identifiers for IAP
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    bool alarmpackpurchased = [defaults boolForKey:@"Alarm_Pack"];
    bool annoyancepackpurchased = [defaults boolForKey:@"Annoyance_Pack"];
    bool serenepackpurchased = [defaults boolForKey:@"Serene_Pack"];

    // Defualt index will always be allowed to save
    if(indexPath.section == 0) {
        savebuybutton.enabled = YES;
        savebuybutton.title = @"Save";
        savebuybutton.tintColor = [UIColor blueColor];
    }
    else {

        if (indexPath.section == 1 && alarmpackpurchased == TRUE) {
            savebuybutton.enabled = YES;
            savebuybutton.title = @"Save";
            savebuybutton.tintColor = [UIColor blueColor];
        }
        else if (indexPath.section == 2 && annoyancepackpurchased == TRUE) {
            savebuybutton.enabled = YES;
            savebuybutton.title = @"Save";
            savebuybutton.tintColor = [UIColor blueColor];
        }
        else if (indexPath.section == 3 && serenepackpurchased == TRUE) {
            savebuybutton.enabled = YES;
            savebuybutton.title = @"Save";
            savebuybutton.tintColor = [UIColor blueColor];
        }

        else {
            savebuybutton.enabled = YES;
            savebuybutton.title = @"Buy Pack";
            savebuybutton.tintColor = [UIColor redColor];
        }
    }
}

viewWillAppear:通知オブザーバーを使用したメソッドは次のとおりです。

- (void)viewWillAppear:(BOOL)animated {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(productPurchased:) name:IAPHelperProductPurchasedNotification object:nil];
}

この製品の IAP を完了した後に受け取るエラーは次のとおりです。

2013-04-19 10:08:12.086 SleepLabBeta[43395:c07] -[AlarmSelectViewController productPurchased:]: unrecognized selector sent to instance 0x11444940
2013-04-19 10:08:12.125 SleepLabBeta[43395:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AlarmSelectViewController productPurchased:]: unrecognized selector sent to instance 0x11444940'
*** First throw call stack:
(0x1bf5012 0x1666e7e 0x1c804bd 0x1be4bbc 0x1be494e 0x11274f9 0x1c4f0c5 0x1ba9efa 0x105bbb2 0x1f57a 0x1f0b3 0x1eeae 0x924b1 0x1b978fd 0x92437 0x930fa 0x93d27 0x922a4 0x227653f 0x2288014 0x22787d5 0x1b9baf5 0x1b9af44 0x1b9ae1b 0x1a3e7e3 0x1a3e668 0x5aaffc 0x297d 0x28a5)
libc++abi.dylib: terminate called throwing an exception
4

2 に答える 2