-2
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"mnuSelected"])
{
ViewController *v = segue.destinationViewController;
if(self.searchDisplayController.active) {
NSIndexPath *indexPath = nil;
indexPath = [self.searchDisplayController.searchResultsTableView indexPathForSelectedRow];
v.str = [self.result objectAtIndex:indexPath.row];
NSIndexPath *rowSelected = nil;
rowSelected = [self.searchDisplayController.searchResultsTableView indexPathForSelectedRow];
v.UserSelected = rowSelected.row; //error in this line
}
else {
NSIndexPath *indexPath = nil;
indexPath = [self.tableView indexPathForSelectedRow];
v.str = [self.monthName objectAtIndex:indexPath.row];
NSIndexPath *rowSelected = nil;
rowSelected = [self.tableView indexPathForSelectedRow];
v.UserSelected = rowSelected.row;
}
return; }
}
我有錯誤在這條線:v.UserSelected = rowSelected.row; 錯誤是:(又名「長」)到「的NSString *」與圓弧不允許「NSInteger的」隱式轉換「NSInteger的」的隱式轉換(又名「長」),以「的NSString *」是不允許的弧形
try v.UserSelected = [nsstring stringwithformat:@「%d」,rowSelected.row]; – iOS
如何在'ViewController'中聲明'UserSelected'?據說'NSString'。爲什麼一個'NSString'?爲什麼不是'NSInteger'? – Larme
UserSelected是一個? int,long,string?請在您的問題中指定它 –