1

ある iOS デバイスから別の iOS デバイスにデータを送信すると、これらのエラーが発生します。

2012-06-21 10:22:15.509 BulletTime[2324:707] -[DataHandler selectorToCall:]: 認識されないセレクターがインスタンス 0x19bfc0 に送信されました 2012-06-21 10:22:15.511 BulletTime[2324:707 ] uncaught exception 'NSInvalidArgumentException', reason: '-[DataHandler selectorToCall:]: unrecognized selector sent to instance 0x19bfc0' * First throw call stack: (0x356c188f 0x37a68259 0x356c4a9b 0x356c3915 0x3561e650 0x356207d3 0xb6fd1 0xb7121 0x3322f61b 0x3561b3fd 0x33110e07 0x33110dc3 0x33110da1 0x33110b11 0x33111449 0x3310f92b 0x3310f319 0x330f5695 0x330f4f3b 0x372b422b 0x35695523 0x356954c5 0x35694313 0x356174a5 0x3561736d 0x372b3439 0x33123cd5 0xb231f 0xb22c4) 例外をスローして終了します (lldb)

このコードがクラッシュの原因であることは確かですが、修正方法がわかりません。

- (void)sendInfo {
    //Attempting to send info to the other device.
    //Returns to the Data Handler.
    info = (BOOL*)YES;

    //Sets the requestLabel and requestData of the CameraRequestDataProvider object.
    //These are then handled in the DataHandler...
    requestLabel = @"Cam";
    requestData = [@"Cam" dataUsingEncoding:NSUTF8StringEncoding];

    //Crash occurs here...

    if (delegateToCall && [delegateToCall respondsToSelector:selectorToCall])

        [delegateToCall performSelector:@selector(selectorToCall:)];
}

私は運が悪いので、過去数日間これを理解しようとしてきました。何か案は?よろしくお願いします!

とった!ありがとう、私はそのエラーを修正しました。

ただし、現在、次のエラーが発生しています。

2012-06-21 10:47:16.779 BulletTime[2416:707] ButtonIndex 0、情報をここに送信する必要があります。2012-06-21 10:47:19.913 BulletTime[2416:707] BTM: デバイス「Grace's iPad」でサービス 0x00000800 に接続しようとしています A4:67:06:F3:EC:2A 2012-06-21 10:47: 20.929 BulletTime[2416:707] BTM: デバイス "Grace's iPad" A4:67:06:F3:EC:2A のサービス 0x00000800 への接続が成功しました 2012-06-21 10:47:22.029 BulletTime[2416:707] -[DataHandler selectorToPerformWhenConnectionWasStablished:]: 認識されないセレクターがインスタンス 0x1303f0 2012-06-21 10:47:22.032 BulletTime[2416:707]に送信されましたインスタンス 0x1303f0' へ *First throw call stack: (0x356c188f 0x37a68259 0x356c4a9b 0x356c3915 0x3561e650 0x356207d3 0x6c693 0x351cf4ff 0x3568d547 0x35619097 0x351433eb 0x6ce1f 0x3069612f 0x356201fb 0x351e4747 0x35695ad3 0x3569529f 0x35694045 0x356174a5 0x3561736d 0x372b3439 0x33123cd5 0x6b2df 0x6b284) terminate called throwing an exception

4

2 に答える 2

2
if (delegateToCall && [delegateToCall respondsToSelector:selectorToCall])

    [delegateToCall performSelector:selectorToCall];

メソッドの同じ間違い

- (void)cancelInfo:(id)sender {
    [mainViewController dismissModalViewControllerAnimated:NO];
    [delegateToCall performSelector:@selector(selectorToCall:)];    
}

に置き換える必要があります

- (void)cancelInfo:(id)sender {
    [mainViewController dismissModalViewControllerAnimated:NO];
    [delegateToCall performSelector:selectorToCall];    
}

アップデート:

ファイル Device.m メソッドの同じエラー:

- (void)triggerConnectionSuccessfull:(NSNotification *)notification

文字列を置換

[delegateToCallAboutConnection performSelector:@selector(selectorToPerformWhenConnectionWasStablished:)];

弦に

[delegateToCallAboutConnection performSelector:selectorToPerformWhenConnectionWasStablished];

と方法

- (void)triggerConnectionFailed:(NSNotification *)notification

も同じエラーがあります

于 2012-06-21T14:45:32.363 に答える
0

CameraDataProvidergithub ソースの 105 行目または 110 行目にメンバー変数 selectorToCall を設定しています。つまり、 performSelector 呼び出しの最後にコロンは必要ありません。

selectorToCall に設定されているセレクターを探す代わりに、

 [delegateToCall performSelector:@selector(selectorToCall:)];

1 つのパラメーターを受け取る名前を持つ DataHandler のメソッドを探していselectorToCallます (コロンのため)。

于 2012-06-21T14:49:01.097 に答える