i am having a programatically created NSCollectionview
_upcomingVideosCollection = [[NSCollectionView alloc] initWithFrame:NSRectFromCGRect(CGRectMake(0, 0, 300, 1200))];
_upcomingVideosCollectionItem = [Videos new];
Videos.m
#import "Videos.h"
@property (strong, retain) IBOutlet NSButton *href_reject;
@end
int i=0;
@implementation Videos
- (void)viewDidLoad {
[super viewDidLoad];
}
-(void)setRepresentedObject:(id)representedObject{
[super setRepresentedObject:representedObject];
if (representedObject !=nil)
{
[_href_reject setTag:i];
i=i+1;
}
}
- (IBAction)removeVideo:(id)sender {
nslog(@"%d",[sender tag])
}
@end
When i am trying to load new data in the collectionview using
[_upcomingVideosCollection setItemPrototype:[Videos new]];
[_upcomingVideosCollection setContent:contents];
the new items [sender tag] are not refreshed and they increment
Ex: first data load, i have 3 objects in contents so the tag would be from 0-2 When i am loading another contents ex:10 objects, instead of 0-9 i have 0-11.
**UPDATE:
@vitormm
Solved the problem using [collection setContent:@[]];
before the real setContent