Re: looking for code snippet
Re: looking for code snippet
- Subject: Re: looking for code snippet
- From: David Remahl <email@hidden>
- Date: Fri, 11 Oct 2002 23:26:34 +0200
>
I am new to cocoa programming but not to mac programming. I am looking
>
for a chunk of sample code that demonstrates selecting a textfile on
>
disk with a "GetFile" (or what ever it is called in cocoa) dialog. Do
>
I need to get into the NSDocument stuff or can I simply open the file,
>
read it in and go from there?
- (IBAction)showOpenDialog:(id)sender
{
NSOpenPanel *openPanel = [NSOpenPanel openPanel]
//set properties on the open panel
[openPanel beginSheetForDirectory:nil file:nil types:[NSArray
arrayWithObjects:@"jpeg", @"jpg"] modalForWindow:nil modalDelegate:self
didEndSelector:@selector(openImagePanelDidEnd:returnCode:contextInfo:)
contextInfo:NULL];
}
- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode
contextInfo:(void *)contextInfo
{
if( returnCode == NSFileHandlingPanelOKButton )
{
NSArray *files = [sheet filenames];
// do stuff with the paths in files
}
}
/ Regards, David Remahl
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.