我有一个prepareforsegue,在其中我检查segue标识符,如果它等于一个字符串,问题是这个if语句失败,尽管两个字符串相等。我注释掉了if语句和我的项目是否正常工作,但为什么这个if语句在它们看起来相等时失败了呢?
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
NSLog(@"Photos stored are %@", self.photos);
if([sender isKindOfClass:[UITableViewCell class]]){
NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
if(indexPath){
NSLog(@"segue identifier is %@", segue.identifier); // this outputs segue identifier is recentPhoto
// the if statement here fails
if([segue.identifier isEqualToString:@"recentPhoto"]){
if ([segue.destinationViewController respondsToSelector:@selector(setImageURL:)]) {
NSURL *url = [FlickrFetcher urlForPhoto:self.photos[indexPath.row] format:FlickrPhotoFormatLarge];
[segue.destinationViewController performSelector:@selector(setImageURL:) withObject:url];
[segue.destinationViewController setTitle:[[self.photos objectAtIndex:indexPath.row] objectForKey:FLICKR_PHOTO_TITLE]];
}
}
}
}
}