Lỗi này có ý nghĩa gì?[__NSCFNumber length]: bộ chọn không được nhận dạng được gửi tới trường hợp 0x6d21350
[__NSCFNumber length]: unrecognized selector sent to instance 0x6d21350
Đây là mã của tôi:
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];
}
}
}];
tôi đã cố gắng debuggin, và nó chết khi nó đi vào performRequestWithHandler. Nó đi khối khác và chết với lỗi ở trên.
Nhiều khả năng, có vấn đề với quản lý bộ nhớ của mình và thời gian chạy/khung là mong đợi một NSString không có ở đó nữa (từ deallocation sớm) và NSNumber đã được cấp phát ở đó. Nếu bạn cố gắng gửi 'length' đến' NSNumber', trình biên dịch hy vọng sẽ cảnh báo bạn. – dreamlax
Không nếu 'NSNumber' được chuyển vào từ điển hoặc thông qua một số giao diện khác xóa các loại. Nhưng bạn nói đúng, có khả năng là anh ấy sẽ phát hành một thứ gì đó. Có thể nên thử với 'NSZombieEnabled'. – zoul
Bạn có ý gì khi "xóa các loại"? – dreamlax