I am creating NSCollection View (in Cocoa) with many identical buttons in size and appearance, except for their icons (or you could probably call them Background Images).
In my xib file I have the button binded to the Collection View (Model key path: representedObject.foto) and the Array Controller has class of MyButton and Keys: foto.
I created My Button class with NSImage property - is this the right way to do it? How do I set an Image that I have in my project in AppController.m so that it appears on the button when running my app?
Everything else should be fine, because I have previously create NSCollectionView with Labels and it worked.
MyButton.h
#import <Cocoa/Cocoa.h>
@interface MyButton : NSButton
@property(retain, readwrite) NSImage *foto;
@end
MyButton.m
#import "MyButton.h"
@implementation MyButton
@end
AppController.h
@interface AppController : NSObject {IBOutlet NSArrayController *controller;}
@property (strong) NSMutableArray *modelArray;
@end
AppController.m
#import "AppController.h"
#import "MyButton.h"
@implementation AppController
- (void) awakeFromNib {
MyButton *FirstOne = [[MyButton alloc] init];
//FirstOne.foto = ???
_modelArray = [[NSMutableArray alloc] init];
[controller addObject:FirstOne];}
@end