mardi 2 décembre 2014

Issue with passing a variable through prepareForSegue method

I am getting an error that I can't seem to solve:



*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[UICollectionViewController setSearchString:]: unrecognized
selector sent to instance 0x7fcd4b655930'


The error comes when I call a prepareForSegue method:



- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{

NSString *searchStringToPass = [[NSString alloc]initWithFormat:_inputField.text];
UINavigationController *navController = [segue destinationViewController];
ResultsCollectionViewController *rvc = (ResultsCollectionViewController *)([navController viewControllers][0]);
NSLog(@"Search String to Pass is: %@", searchStringToPass);
//[rvc setSearchString:searchStringToPass];
rvc.searchString = searchStringToPass;
//userViewController.user = [self.users objectInListAtIndex:[self.tableView indexPathForSelectedRow].row];

}


The ViewController that I am trying to get to is imbedded in a navigation controller. The code for it is:



#import "ResultsCollectionViewController.h"

@interface ResultsCollectionViewController ()
//@property(nonatomic, weak) IBOutlet UICollectionView *collectionView;
@property(strong, nonatomic) NSArray *flickrPhotos;


@end

@implementation ResultsCollectionViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"search string is %@",_searchString);
}

-(void)getFlickrPhotosWithSearchString:(NSString*)searchString{


}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}


And the .h file is:



#import "BaseViewController.h"

@interface ResultsCollectionViewController : BaseViewController <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
@property (strong, nonatomic) NSString *searchString;



@end


Anybody have any idea what the issue is? Many thanks in advance.




Aucun commentaire:

Enregistrer un commentaire