Я пытаюсь передать выбранный объект в моем представлении коллекции другому контроллеру представления через segue. Когда я нажимаю на одну ячейку в коллекции просмотра аварий приложений и дает мне эту ошибку:[ViewController row]: непризнанный селектор, отправленный экземпляру в collectionView didSelectItemAtIndexPath
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController row]: unrecognized selector sent to instance 0x136d1fbf0
Вот как я это делаю:
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
_friends = [[NSMutableArray alloc] init];
[self refresh];
}
- (void)refresh {
PFQuery *query = [PFQuery queryWithClassName:@"People"];
[query orderByDescending:@"createdAt"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (error) {
NSLog(@"Error: %@ %@", error, error.userInfo);
} else {
[self.collectionView reloadData];
}
}];
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
NSLog(@"Do nothing");
} else {
[self performSegueWithIdentifier:@"profilePush" sender:self];
}
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
FriendsTableViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FriendsTableViewCell" forIndexPath:indexPath];
cell.friendsDelegate = self;
PFObject *friendObj = [_friends objectAtIndex:indexPath.row];
[(PFFile*)friendObj[@"profilePic"] getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
if (error) {return;}
cell.profilePic.image = [UIImage imageWithData:data];
}];
cell.nameL.text = friendObj[@"username"];
return cell;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
if (section == 0) {
return 3;
} else {
return _friends.count;
}
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 2;
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"profilePush"]) {
NSIndexPath *indexPath = (NSIndexPath*)sender;
ProfilePopupViewController *person = segue.destinationViewController;
person.user = [_friends objectAtIndex:indexPath.row];
//.user is a PFObject in the next view controller
}
}
@end