Ok some more details:

I removed the subclassing of NSTextView entirely just to eliminate that as any sort of source for the problem so now:

In my document nib I have a regular NSTextView, bound via IBOutlet to a variable in the document class. However still the NSTextView only responds to updating its content when the document is instantiated via new/open rather than when created programatically. Is there some binding I need to do instead of IBOutlet NIB binding to get that view to respond? Does new/open somehow alloc init the variable differently? IE am I supposed to alloc init the NSTextView in the Document init, or was this supposed to be handled by IB?

Puzzling on..

Richard

On Dec 31, 2008, at 1:58 PM, Richard Ashwell wrote:

Ok,

First this is cry for help. Second I suck at the cocoa dev thing so I anticipate that I won't even describe this very well, please forgive my lack of skill in Cocoa Dev, but here goes:

I have built a relatively complex application, but have dug a whole I can't fix or dig out of. I built the app on the Document Core Data model, but this isn't really a core data issue (As in I haven't gotten that deep into that part). My app was a little different (I think) in that I wanted a controlling Main Window to be able to select / open documents from rather than just the New/Open mechanisms provided by the template.

To facilitate this

1) I overrode: applicationShouldOpenUntitledFile: to return NO so that an untitled document wouldn't pop up. 2) Then I added a Window to the MainMenu Nib and added lots of code / bindings etc to have a table of documents to choose from etc, the idea here is there that the application overall is really a database of individual documents. 3) I was pretty pleased to get all of this working, and the "New/ Open" still functions for opening or creating individual documents, so I haven't broken anything there yet. 4) The next task was based on a selection in the database table, I wanted to programatically open a document and pre populate it from the data.

Here I ran into the issue that the document from the template was tied to Nib via the Overridden windowNibName: method, which made it difficult to programmatically get the Controller Window when creating a new document from elsewhere in the code. The solution I have here is to comment out the windowNibName method and instead implement:

- (void)makeWindowControllers
{
NSWindowController *mainWindowController = [[NSWindowController alloc] initWithWindowNibName:@"MyDocument" owner:self];
        
        [mainWindowController setShouldCloseDocument:YES];
        [self addWindowController:mainWindowController];
        [mainWindowController showWindow:self];
}

This worked and I could instantiate an instance of my Document Class programatically when ever I want and call method makeWindowControllers on it and the document would come up, more importantly I could then setup the instantiated Document to have its data loaded. This all is working with one exception:

Problem:

One view in my document nib is an NSTextView that I have A) Subclassed and in IB set it to the Subclass, and B) IBOutleted to the main document class for a variable there. Note this works when creating new/open documents from the templates (I assume because the Nib basically instantiates an instance of the sub class, and binds it for me via the IBOutlet). Nice and dandy, however:

When I create the new document programatically (and I think/guess this is my issue) perhaps I am getting two instantiations of the Subclassed NSTextView or somehow when I create programatically my document class isn't getting bound via the IBOutlet. I am only guessing and I don't know how to troubleshoot here, which is why I am begging for help.

More details:
At this point I removed ALL functionality from the NSTextView subclass leaving only a single method that is passed an NSMutableAttributedString and all the method does is set the text storage of itself and increases the font size etc, and again this method is called and works via the new/open document stuff, but fails when called programatically, I have traced to see that the string passed in both cases is occurring, but since nothing shows up in the view when I do it programatically, my only guess is that it is some how a different instance of the subclass?

Any and all help is appreciated, I will happily code pieces etc, but the application is a little large to link the whole thing here, but If someone has any ideas please please, help me trouble shoot this.

Regards,
Richard Ashwell




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/rashwell%40me.com

This email sent to rashw...@me.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to