views:

20

answers:

2

Hi,

I'm quite new to the Mac but reasonably expirienced with windows. What I need is a window owned opened and closed by the library (dylib). This is very easy to do in MS Windows but seemsnto be hard under Cocoa.

I used the code from apple's 'CocoaInCarbon' example with C++ Wrappers. But the 'NSApplicationLoad()' followed by 'NSBundle LoadNibNamed:@"MyWindow" owner:self] fails. Is this caused by the dylib not being a bundle.

Are there alternative ways to open and control a window within a dylib?

+2  A: 

Yes, the problem is that it's not a bundle; your nib can't possibly be inside a bundle that doesn't exist, so how would the code find it to open it?

You need to either use a framework (which is a bundle), and ship the nib in that framework, or you need to create the entire window programmatically in your dylib.

smorgan
Ok, thank you, I get it. Are you aware of samplecode illustrating solution A and or B?Jan
Jan
A: 

It's not a standard practice to just ship dylib on Mac, when the shared library is not very low level and involves GUI in particular. You package it into a framework, so that it can not only have codes in it, but associated resources (nibs, images, sounds) in one place.

Read this Apple document to understand what's going on and how to prepare it. Or, take a look at /System/Library/Frameworks/ to see how the OS X itself provides libraries.

Yuji