2012-04-10 4 views
20

このエラーは何を意味しますか?[__NSCFNumber length]:インスタンスに送信された認識できないセレクタ0x6d21350

[__NSCFNumber length]: unrecognized selector sent to instance 0x6d21350 

は、ここに私のコードです:

NSString *urlString = @"http://api.twitter.com/1/statuses/update.json"; 
    NSURL *url = [NSURL URLWithString:urlString]; 

    NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; 
    [params setObject:status forKey:@"status"]; 
    [params setObject:replyToID forKey:@"in_reply_to_status_id"]; 
    [params setObject:@"1" forKey:@"include_entities"]; 

    // Build the request with our parameter 
    TWRequest *request = [[TWRequest alloc] initWithURL:url parameters:params requestMethod:TWRequestMethodPOST]; 

    // Attach the account object to this request 
    [request setAccount:twitterAccount]; 

    [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { 
     if (!responseData) { 
      // inspect the contents of error 
      NSLog(@"%@", [error localizedDescription]); 

      self.alert = [[UIAlertView alloc] initWithTitle:@"HTTP error" message:@"I could not connect to the Twitter API." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; 
      [self.alert show]; 

      [self.replyDelegate replyRequestSuccessful:NO]; 
     } 
     else { 
      /*NSString *responseDataAsString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; 
      NSLog(responseDataAsString);*/ 

      NSError *error; 
      NSArray *replyResponse = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&error]; 

      if (!replyResponse) { 
       NSLog(@"%@", [error localizedDescription]); 

       self.alert = [[UIAlertView alloc] initWithTitle:@"JSON error" message:@"I could not parse the JSON response from the Twitter API." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; 
       [self.alert show]; 

       [self.replyDelegate replyRequestSuccessful:NO]; 
      } 
      else { 
       [self.replyDelegate replyRequestSuccessful:YES]; 
      } 
     } 
    }]; 

私はdebugginを試みたが、それはperformRequestWithHandlerに入るとそれが死にます。 elseブロックに行き、上記のエラーで終了します。

答えて

67

またはlengthメソッドを持つ他のオブジェクトが必要な場合は、NSNumberを渡すことを意味します。 Xcodeに例外が発生するように指示して、lengthメソッドがどこに呼び出されるかを確認することができます。

+7

おそらく、彼のメモリ管理に問題があります。ランタイム/フレームワークはもはや(早すぎる解放から)存在しないNSStringを期待しており、代わりにNSNumberが割り当てられています。意図的に 'length 'を' NSNumber'に送りつけようとすると、コンパイラはうまく警告します。 – dreamlax

+0

'NSNumber'がディクショナリや型を消去する他のインタフェースを通って渡されない場合は、しかし、あなたは正しい、彼は何かを過剰にリリースしている可能性が高いです。 'NSZombieEnabled'を試してみることをお勧めします。 – zoul

+0

「タイプを消去する」とはどういう意味ですか? – dreamlax

6

具体コード行:

[params setObject:replyToID forKey:@"in_reply_to_status_id"]; 

replyToID文字列でない場合、またはメソッドlengthを有しています。これを持っていない場合、またはreplyToIDをparamsに設定する前に文字列に変換すると動作します。

関連する問題