I am creating a CollectionView application. where I get data from the server through a JSON string. and my workflow is as follows
@interface ProjectCollectionViewCell: UICollectionViewCell
@property (weak, non-nuclear) IBOutlet UIImageView * projectImage,
@property (weak, non-nuclear) IBOutlet UILabel * projectLabel;
@end
The code for .m is by default and synthesized the above 2 variables. and .xib has a View Cell collection with an image and label (linked the above class to the collection view cell and linked the identifier name as "projectCell".
- The code for the ViewController containing the collectionView is as follows
Code inside for ViewController.m
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section{
return [projectList count];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
{
ProjectCollectionViewCell *cell = (ProjectCollectionViewCell *)[cv dequeueReusableCellWithReuseIdentifier:@"projectCell" forIndexPath:indexPath];
cell.projectLabel.text = @"";
return cell;
}
in the "Above code" box. I need a problem.
[UICollectionViewCell projectLabel]: unrecognized selector sent to instance 0x75f0fb0
2013-02-07 20:08:17.723 Sample[3189:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICollectionViewCell projectLabel]: unrecognized selector sent to instance 0x75f0fb0'
*** First throw call stack:
The cell value is beautiful, I made sure that projectLabel after "." Is also taken with NSLog and code hint. But I can not set the value of the label field with this. So please help me.
source
share