我不断收到错误:
NSInvalidArgumentException',原因:'-[UIViewController setPhotoCellName:]:无法识别的选择器发送到实例
当我进入我的 segue 呼叫准备时。目前我有
TabBarController->NavigationController->TableViewController->TableViewController->ViewController
上面有一个 UI 图像。
当我尝试从第二个 TableView 控制器转移到 ViewController 时,就会出现问题。我有从 Prototype Cell 到实际 ViewController 的 segue 设置。它进入segue并崩溃。我正在尝试将NSArray
属性传递给 ,viewController
以便能够在其中使用 URL 并显示UIImage
. PhotoInPlace 包含我试图传递的数组。这是代码。
myTableViewControllerPhotoLocation.m 代码
#import "myTableViewControllerPhotoLocation.h"
#import "FlickrImageViewController.h"
@interface myTableViewControllerPhotoLocation ()
@end
@implementation myTableViewControllerPhotoLocation
@synthesize photoInPlace = _photoInPlace; //Contains NSArray to pass
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:@"Photo Display"]){
NSIndexPath* indexPath = [self.tableView indexPathForCell:sender];
NSLog(@" Dicitonary = %@", [self.photoInPlace objectAtIndex:indexPath.row]); //Returns the picked cell
NSLog(@"%@", [self.photoInPlace class]); //returns NSArray
NSLog(@"%@", [self photoInPlace]); //Returns the array
[segue.destinationViewController setPhotoCellName:[self.photoInPlace objectAtIndex:indexPath.row]];
//Crashes HERE!
}
}
FlickrImageViewController.h 代码
@property (nonatomic, strong) NSArray* photoCellName;
FlickrImageViewController.m 代码
#import "FlickrImageViewController.h"
@interface FlickrImageViewController ()
@end
@implementation FlickrImageViewController
@synthesize photoCellName = _photoCellName; //property declared in header
-(void) setPhotoCellName:(NSArray *)photoCellName{
if(!_photoCellName)
_photoCellName = [[NSArray alloc] initWithArray:photoCellName];
else {
_photoCellName = photoCellName;
}
}