2

全て。私はobjective-cが初めてで、PupupButtonを接続して、接続されたUSBハードドライブなどのボリュームのリストを表示する方法に関する質問です...選択可能になります:

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
// -- //

これは私の.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
}

デバイスのリスト (取り外し可能かどうか) が必要ですが、次のエラーが表示されます。

 - [__NSArrayI IsEqualToString:]: unrecognized selector sent to instance 0x60800001e110

また、ディスク識別子を plist ファイルに書き込みたいのですが、上記のエラーで停止しました。

何かアドバイス?

4

1 に答える 1