In my app I have parsed images in Collectionview cells that segue when pressed to another screen with the larger image. This works fine. But, when I try to add a label that contains an array of strings to the same destination view controller I get :
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0xaaa7520'
Each array, the image and string have the same amount of indexes.
In First View Controller
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"BottomSegue"]) {
//DetailShowImageViewController *detailedVC = segue.destinationViewController;
//detailedVC.detailImageView =sender;
NSArray *indexPaths = [self.bottomCollectionview indexPathsForSelectedItems];
NSLog(@"%@", indexPaths);
BottomCollectionDetail *destinationVC =segue.destinationViewController;
NSIndexPath *indexPath = [indexPaths objectAtIndex:0];
NSLog(@"%@", indexPath);
destinationVC.imageFromArray = [bottomArray objectAtIndex:indexPath.row];
destinationVC.string = [arrayOfTitles objectAtIndex:indexPath.row];
[self.bottomCollectionview deselectItemAtIndexPath:indexPath animated:YES];
}
destinationVC.h
@property (weak, nonatomic) IBOutlet UILabel *labelOne;
@property (weak, nonatomic) IBOutlet UIImageView *imageViewBCD;
@property(weak, nonatomic) NSString *string;
@property(weak, nonatomic)UIImage *imageFromArray;
destinationVC.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.imageViewBCD.image = _imageFromArray;
self.labelOne.text = _string; //This is the line of code that is causing exception
}
My issue is trying to get the label to show the string, that is throwing the exception. Is there anyway I can fix this?
arrayOfTitles?self.labelOne.text = [NSString stringWithFormat:@"%@",_string]arrayOfTitlesis a NSString not an NSArray