all. I'm new in objective-c, and my question regard how to connect my PupupButton to see a list of my volumes as attached USB hard drive etc...to be selectable:
MyController.h
@interface MyController : NSWindowController <NSWindowDelegate, NSTableViewDataSource, NSTabViewDelegate, NSApplicationDelegate, NSOpenSavePanelDelegate>
{
@private
#if !__has_feature(objc_arc)
NSPopUpButton *_targetdevicePopup;
// etc
#endif
NSArray*_arrayTargetdevice;
}
#if !__has_feature(objc_arc)
@property (nonatomic, retain) IBOutlet NSPopUpButton *targetdevicePopup;
//etc
#else
@property (assign) IBOutlet NSPopUpButton *targetdevicePopup;
/etc
#endif
// -- //
this on my .m:
#import "MyController.h"
#import "AppDelegate.h"
#import <IOKit/IOKitLib.h>
#import <DiskArbitration/DiskArbitration.h>
@interface MyController ()
@end
@implementation MyController
#if !__has_feature(objc_arc)
@synthesize targetdevicePopup = _targetdevicePopup;
//etc
#endif
#if !__has_feature(objc_arc)
- (void)dealloc
{
[_targetdevicePopup release];
//etc
}
#endif
- (id)init
{
self = [super initWithWindowNibName:@"MyController"];
if (self) {
}
return self;
}
- (void)windowDidLoad
{
[super windowDidLoad];
//more code
_arrayTargetdevice = [[NSArray alloc] initWithObjects:
[[NSWorkspace sharedWorkspace] mountedRemovableMedia], nil];
[_targetdevicePopup addItemsWithTitles:_arrayTargetdevice];
for (int i = 0; i <= [_arrayTargetdevice count]; i++) {
[[_targetdevicePopup itemAtIndex:i] setTag:i];
}
[[[_targetdevicePopup menu]
itemWithTitle:@"Not Selected"] setTitle:NSLocalizedString(@"Not Selected", nil)];
//more code
}
I would like a list of my devices (removable and not), but I get this error:
- [__NSArrayI IsEqualToString:]: unrecognized selector sent to instance 0x60800001e110
I would also like to write disk identifier on to a plist file ... but I stopped on the error above.
Any advice?
Wrong initialization of the array
It should be