我試圖創建這個應用程序,當你按一個tablecell時顯示ViewController,而變量get的設置在另一個視圖控制器中。儘管當我按下uitablecell時,出現了一些錯誤。Objective C - [__ NSCFString _isAncestorOfFirstResponder]錯誤
錯誤:
2013-04-06 22:47:25.970 iFSX Guide[1069:907] Called
2013-04-06 22:47:26.009 iFSX Guide[1069:907] -[__NSCFString _isAncestorOfFirstResponder]: unrecognized selector sent to instance 0x1d562390
2013-04-06 22:47:26.016 iFSX Guide[1069:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString _isAncestorOfFirstResponder]: unrecognized selector sent to instance 0x1d562390'
*** First throw call stack:
(0x319b22a3 0x3964c97f 0x319b5e07 0x319b4531 0x3190bf68 0x33832beb 0x338a837f 0x338548fb 0x33a95619 0x338a79b9 0x338a5fe7 0x339c83ef 0xa22a5 0x3387c28d 0x338fef81 0x322c0277 0x319875df 0x31987291 0x31985f01 0x318f8ebd 0x318f8d49 0x354ba2eb 0x3380e301 0xa19d1 0x39a83b20)
libc++abi.dylib: terminate called throwing an exception
代碼:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)in dexPath{
NSLog(@"Called");
Aircraft = indexPath.row;
[self performSegueWithIdentifier:@"ToSections" sender:self];
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:@"ToSections"]){
AirplaneSections *sections = (AirplaneSections *)segue.destinationViewController;
sections.plane = Aircraft;
}
}
我發現,它是在視圖控制器viewDidLoad方法上的錯誤。
NSString *quickTemp = [NSString alloc];
switch (plane) {
case 0:
quickTemp = @"Boeing 737-800";
break;
default:
break;
}
TitleLabel.text = quickTemp;
*/
我在那裏做錯了。
'飛機'是什麼樣的屬性?你在使用ARC嗎? – omz 2013-04-06 20:54:33
飛機是一個「int」,是的,我使用ARC – 2013-04-06 21:19:29