• 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: Nib not awoken
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Nib not awoken


  • Subject: Re: Nib not awoken
  • From: Ross Carter <email@hidden>
  • Date: Tue, 15 Feb 2011 12:54:56 -0500

On Feb 15, 2011, at 10:49 AM, Bruce Cresanta wrote:

> 	I am using an NSDocument based application and I'm having trouble with the following code:
>
> -(void) analyzePressed
> {
> 	NSString * raw = [[[NSString alloc]  initWithBytes:[pageData bytes] length:[pageData length] encoding: NSUTF8StringEncoding] retain];
> 	id analyzerdocument = [[NSDocumentController sharedDocumentController] openUntitledDocumentOfType:@"AnalyzerType" display:YES];
>
> 	[analyzerdocument setSourceTextView:raw];
>
>
> }
>
> When I create the document off the sharedDocument controller, the nib hasn't fully awoken until after the setSourceTextView selector is called.   My File's Owner is set correctly with references to a text view.  The setSourceTextView is just a wrapper to [sourceTextView setString:string].   How do I make sure the nib is loaded before calling my set routine?

A few things stand out.

First, openUntitledDocumentOfType:display: was deprecated in 10.4. You probably want openUntitledDocumentAndDisplay:error:.

Second, I think you wrote "retain" when you meant "autorelease," although that has nothing to do with your problem.

Third, I think the place to put code to initialize a new document is in your NSDocument subclass. For a new, untitled document, you can override initWithType:error:.

Finally, I don't follow how your nib is set up. The File's Owner of a nib is a NSTextView? It sounds to me (and forgive me if I am wrong) that your project suggests a misunderstanding of the relationship among the document, the window controller, the window, and nib that cannot be determined from the information provided.

Ross
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Nib not awoken (From: Bruce Cresanta <email@hidden>)

  • Prev by Date: Re: Re: Sharing a model
  • Next by Date: Re: Sharing a model
  • Previous by thread: Nib not awoken
  • Next by thread: Contextual menu commands in the Finder
  • Index(es):
    • Date
    • Thread