• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: looking for code snippet
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >looking for code snippet (From: "Tom Meehan" <email@hidden>)

  • Prev by Date: Application is crashing if it runs for long time (On NSTask)
  • Next by Date: Re: Toronto cocoa programmers?
  • Previous by thread: looking for code snippet
  • Next by thread: Application is crashing if it runs for long time (On NSTask)
  • Index(es):
    • Date
    • Thread