Reputation: 809
I just implemented a collection view within a collection view cell as property
#import <UIKit/UIKit.h>
#import "EMSubCollectionView.h"
@interface EMYearCell : UICollectionViewCell
-(void)setCollectionViewDataSourceDelegate:(id<UICollectionViewDataSource>)dataSourceDelegate index:(NSInteger)index currentSection:(NSInteger)section;
@property (strong, nonatomic) IBOutlet EMSubCollectionView *collectionView;
@property (strong, nonatomic) IBOutlet UILabel *monthHeader;
@end
The method in my implementation looks like this:
-(void)setCollectionViewDataSourceDelegate:(id<UICollectionViewDataSource>)dataSourceDelegate index:(NSInteger)index currentSection:(NSInteger)section
{
self.collectionView.dataSource = dataSourceDelegate;
self.collectionView.tag = index;
self.collectionView.numberOfCurrentSection = section;
[self.collectionView reloadData];
}
I just wanted to give my collection view a second "tag-property", so I subclassed the corresponding collectionview property:
#import <UIKit/UIKit.h>
@interface EMSubCollectionView : UICollectionView
@property NSInteger numberOfCurrentSection;
@end
When I run my app, it immediately crashes:
What is wrong with my code? Thanks in advance.
Upvotes: 0
Views: 988
Reputation: 809
Solution was pretty simple: I just forgot to assign the new class to the corresponding collection view in my storyboard. Now everything works like a charm.
Upvotes: 3