-1

このコードを入力しようとすると、Xcode から「宣言されていない識別子 'completedWithResult' の使用」と表示されます。これは、Quickblox のプッシュ通知のコードです。コードの一部があります:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    /// Set QuickBlox credentials (You must create application in admin.quickblox.com)
    [QBSettings setApplicationID:XX];
    [QBSettings setAuthorizationKey:@"XX"];
    [QBSettings setAuthorizationSecret:@"XX"];
    //
    // If you use Push Notifications - you have to use lines bellow when you upload your application to Apple Store or create AdHoc.
    //

    [QBSettings useProductionEnvironmentForPushNotifications:YES];

    QBASessionCreationRequest *extendedAuthRequest = [QBASessionCreationRequest request];
    extendedAuthRequest.devicePlatorm = DevicePlatformiOS;
    extendedAuthRequest.deviceUDID = [[UIDevice currentDevice] uniqueIdentifier];
    extendedAuthRequest.userLogin = @"yourUserLogin";
    extendedAuthRequest.userPassword = @"yourUserPassword";

    [QBAuth createSessionWithExtendedRequest:extendedAuthRequest delegate:self];

    // QuickBlox queries delegate
    - (void)completedWithResult:(Result *)result{
        if(result.success){

            // Create session result
            if([result isKindOfClass:QBAAuthSessionCreationResult.class]){
                // register for receive push notifications
                [QBMessages TRegisterSubscriptionWithDelegate:self];

                // Register for receive push notifications result
            }else if([result isKindOfClass:QBMRegisterSubscriptionTaskResult.class]){
                // Congrats! Now you can receive Push Notifications!
            }
        }
    }

エラーは次の行にあります。

 // QuickBlox queries delegate
        - (void)completedWithResult:(Result *)result{
            if(result.success){

「宣言されていない識別子「completedWithResult」の使用」と表示されます

誰か助けてください。ありがとう!

4

2 に答える 2

4

他のメソッド内にメソッドを実装しています。これは Objective-C では許可されていません。application:didFinishLaunchingWithOptions:おそらく、メソッドの閉じ括弧を見逃したのでしょう。}上記の 2 番目の ( completedWithResult:) メソッドで閉じます。

于 2013-03-28T12:34:57.660 に答える
2

Objective-C のメソッド内にメソッドを実装することはできません。別のメソッドではなく、クラス内にメソッドを実装していることを確認してください。

まだ理解していない場合、委譲パターンは単純ですが、Cocoa フレームワークの重要な部分です。メソッドをデリゲート クラス内に配置すると、コードの他のコンポーネント (この場合は QBAuth) が呼び出します。それは後で。

于 2013-03-28T12:42:09.803 に答える