• 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: NSDocument and new windows.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDocument and new windows.


  • Subject: Re: NSDocument and new windows.
  • From: Volker Runkel <email@hidden>
  • Date: Tue, 24 May 2005 19:29:58 +0200

Hi,

I am implementing my own Documentbased app at the moment and read a lot int he documentation. There I found for DocumentController that (deprecated in 10.4) it is possible to do

setShouldCreateUI:

I assume there are other possibilities now with tiger...

To get a UI for such a non-ui document possible is possible by creating a new one and setting it to the old ones content.

Volker


Am 24.05.2005 um 12:22 schrieb Teunis Peters:

Okay - I've decided I am as a matter of fact going to use NSDocument in interacting with the database. Permanent links (a record containing enough information to connect to the database) will exist as an NSDocument form.

Okay I've got some problems.
- Can an NSDocument object exist -without- having a window for it?
- How does one create new windows for said document?

I've got new windows opening, but default data is not set and no data in the window is set.... I've got NO idea how to set this up properly - I have yet to find any examples that overload NSWindowController. At least not in xCode 1.5.
I also overload NSDocumentController but that code seems to work okay.


As an added bonus - source for the NSDocument data could be filesystem or database. I'm not sure what to overload to allow the second - NSFileWrapper? the NSURL methods? Still scratching my head on that one.

Current code:  (yes these are extracts)

in Document:
(overloaded: isNativeType, readableTypes, writableTypes, dataRepresentationOfType,loadDataRepresentation and a whole bunch more.
- (void)windowControllerDidLoadNib:(NSWindowController *) windowController {
[super windowControllerDidLoadNib:windowController];
wgCatViewController* cv = (wgCatViewController*)windowController;
[cv setDataFrom:self];
}


- (void)makeWindowControllers {
    controller = [[[wgCatViewController alloc] init] retain];
    [controller setDataFrom:self];
    [self addWindowController:controller];
}

- (NSString *)displayName {
    return [self name];
}

in window controller:
-init {
    if (self = [self initWithWindowNibName:@"dCategory"]){
        // used to log some stuff.  Does nothing now, but IS run.
    }
    return self;
}

- (void)windowWillLoad {
    NSLog(@"%s", __FUNCTION__);
}

- (void)windowDidLoad {
NSLog(@"%s", __FUNCTION__); // this is called. None of this data is reflected in the window.
[desc setStringValue:@"this is only a test"];
if (category) {
[[self window] setTitle:[category name]];
[desc setStringValue:@"testing"];
[icon setImage:[category icon]];
[scroll setHasHorizontalScroller:TRUE];
[scroll setHasVerticalScroller:TRUE];
}
}


- (NSString *)windowTitleForDocumentDisplayName:(NSString *) displayName {
if (category) return [category name];
return [super windowTitleForDocumentDisplayName:displayName];
}


-setDataFrom:(dbcategory*)src {
    category = [src retain];
    if ([self window] && category) {
        [[self window] setTitle:[category name]];
        [desc setStringValue:@"testing"];
        [icon setImage:[category icon]];
        [scroll setHasHorizontalScroller:TRUE];
        [scroll setHasVerticalScroller:TRUE];
    }
}
 _______________________________________________
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

_______________________________________________ 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
References: 
 >NSDocument and new windows. (From: Teunis Peters <email@hidden>)

  • Prev by Date: Re: setNeedsDisplay broken in Tiger
  • Next by Date: xCode fetch predicate view
  • Previous by thread: NSDocument and new windows.
  • Next by thread: Dynamic User Interface with Cocoa
  • Index(es):
    • Date
    • Thread