Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dale.albiston

macrumors member
Original poster
Sep 29, 2006
61
0
assume I have a window in a nib file, the nib file is loaded and the controller has a pointer to it.

I can show this window via:

[myWindow makeKeyAndOrderFront];

this works fine

Q: assume I want a copy of this window, say for example its a property window I may want several of for different data objects. I still wish to define this window in the nib file. how do I create a new window that is a copy of the current one?. I'm assuming there will be a way to create a new object pointer, but how can I tell it to initialise to a copy of another object?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
The window will be owned by a NSWindowController subclass. Create another instance of that and it'll create a copy of window from the nib ready to use.

Having said that it sounds like you are writing a document based app. So choose that template and this will all be handled for you :)
 

dale.albiston

macrumors member
Original poster
Sep 29, 2006
61
0
mmm lets see so if i create a new instance of the controller it will create a new copy of the window i can use?

fair enough i'll have to try.

I have looked at the document approach, not sure how to have several different types of 'document', with different window types though.
 

dale.albiston

macrumors member
Original poster
Sep 29, 2006
61
0
i think i'm getting there, albeit slowly.

been recommended to try and load an instance of the nib file each time i need a window and run that way..

I'm tending towards each window getting a seperate controller object, where the controllers are basically just targets for the clicks and whatnots a window generates, and have any logic required to manipulate the window, a seperate data controller driving it if required (hence two windows talk to one data object)

I think this is how its all meant to work..

pity really, this is one thing thats a non issue with vb.net. i.e. a form is an object and something along the lines of

myWindow *x = [[myWindow alloc] init];

would be all thats required. there may still be a way of doing this with a function to create windows and return an object reference for it.

ohh the joys of porting vb.net to something faster and usable ont he mac
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
I'm tending towards each window getting a seperate controller object, where the controllers are basically just targets for the clicks and whatnots a window generates, and have any logic required to manipulate the window, a seperate data controller driving it if required (hence two windows talk to one data object)

Sounds like what you should do.
pity really, this is one thing thats a non issue with vb.net. i.e. a form is an object and something along the lines of

myWindow *x = [[myWindow alloc] init];

The problem then is that what do you link the IBOutlet's in the window controller to, and how to do you know which window you are connected to? In Cocoa each Window needs a separate window controller instance for each version.

Personally I see your point about VB.NET but I think its the difference between how the API's work and in terms of goodness its really a wash.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.