• 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: How to get an NSWindow from an NSDocument?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get an NSWindow from an NSDocument?


  • Subject: Re: How to get an NSWindow from an NSDocument?
  • From: Scott Ellsworth <email@hidden>
  • Date: Mon, 23 May 2005 13:55:30 -0700


On May 23, 2005, at 9:56 AM, Theodore H. Smith wrote:

I have a document based Cocoa app.

I want to do stuff to it's window, like set the title of the window when I open a file. However, I can't figure out how to get an NSWindow from the NSDocument. I tried this:

I went a different route - instead of fiddling with the window directly, my implementation of readFromURL sets the properties that the window would be reading later to set the title.


The following code is part of a Core Data app that can also read and write "Tab Delimited Sector" and "Sector" files, but since those are lossy, I want an 'untitled' window to show up when you open one.

- (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSError **)outError{
NSLog(@"rFU: %@ %@",absoluteURL, typeName);
if ([typeName isEqualToString:@"Tab Delimited Sector"] || [typeName isEqualToString:@"Sector"]){
NSString * data = [NSString stringWithContentsOfURL:absoluteURL encoding:NSMacOSRomanStringEncoding error:outError];
if (data==nil){
NSLog(@"Error reading file at %@: %@", [absoluteURL path], outError);
return NO;
} else {
[self setFromString:data];
[self setFileType:@"Binary"];
[self setFileURL:nil];
[self refreshEverything];
return YES;
}
} else {
return [super readFromURL:absoluteURL ofType:typeName error:outError];
}
}


This might be an end run around needing to futz with the Window directly.

Scott
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: How to get an NSWindow from an NSDocument?
      • From: mmalcolm crawford <email@hidden>
References: 
 >How to get an NSWindow from an NSDocument? (From: "Theodore H. Smith" <email@hidden>)

  • Prev by Date: Re: ~/library/application support/myapp directory creation
  • Next by Date: Re: Very simple - UNIX like - filename expansion?
  • Previous by thread: Re: How to get an NSWindow from an NSDocument?
  • Next by thread: Re: How to get an NSWindow from an NSDocument?
  • Index(es):
    • Date
    • Thread