Hi all,
I want to display list of files selected with NSOpenPanel in NSTableView with this code:
but when I select files in NSOpenPanel and click Open I get this error:
[NSRectSet objectAtIndex:]: unrecognized selector sent to instance 0x1b9030
When line with
is uncommented everything works fine.
I want to display list of files selected with NSOpenPanel in NSTableView with this code:
Code:
#import <Cocoa/Cocoa.h>
@interface AppController : NSObject {
IBOutlet NSTextField *tagTitle;
IBOutlet NSTableView *filesTableView;
NSArray *openedFiles;
}
- (IBAction)showOpenPanel:(id)sender;
- (void)openPanelDidEnd:(NSOpenPanel*)sheet
returnCode:(int)returnCode
contextInfo:(void*)contextInfo;
@end
Code:
#import "AppController.h"
@implementation AppController
- (IBAction)showOpenPanel:(id)sender
{
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel setCanChooseFiles: YES];
[panel setCanChooseDirectories: NO];
[panel setAllowsMultipleSelection: YES];
NSArray *fTypes = [NSArray arrayWithObjects: @"txt", nil];
[panel beginSheetForDirectory: nil
file: nil
types: fTypes
modalForWindow: [filesTableView window]
modalDelegate: self
didEndSelector: @selector(openPanelDidEnd:
returnCode:
contextInfo:)
contextInfo: nil];
}
- (void)openPanelDidEnd:(NSOpenPanel*)sheet
returnCode:(int)returnCode
contextInfo:(void*)contextInfo
{
if (returnCode == NSOKButton) {
openedFiles = [sheet filenames];
[filesTableView reloadData];
}
// NSRunAlertPanel(@"Test: ", @"Test", nil, nil, nil);
}
- (int)numberOfRowsInTableView:(NSTableView *)tv
{
return [openedFiles count];
}
- (id)tableView:(NSTableView *)tv
objectValueForTableColumn:(NSTableColumn *)tableColumn
row:(int)row
{
NSString *filename = [openedFiles objectAtIndex: 0];
return filename;
}
@end
but when I select files in NSOpenPanel and click Open I get this error:
[NSRectSet objectAtIndex:]: unrecognized selector sent to instance 0x1b9030
When line with
Code:
NSRunAlertPanel(@"Test: ", @"Test", nil, nil, nil);