Skip to content

afrog33k/mcocoa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BUILDING

You'll need to install the mobjc library which you can find at
<http://code.google.com/p/mobjc/>. Once you've done that navigate
to the mcocoa directory with a terminal and and type:
`make update-libraries && make generate && make lib` 
which will copy the mobjc library from usr/local/lib, generate the wrapper
classes, and build the mcocoa library. Then you can type `make check` 
which will run some simple unit tests as a sanity check.

If you want to build for Mac OS 10.5 you can use:
`make OS=10.5 lib`.

INSTALLING

To install type `sudo make install`, to uninstall type `sudo make uninstall`.

By default the libraries are installed into /usr/local/lib. You can 
change this with a command like this: `make INSTALL_DIR=/tmp install`.

Typically you'd copy the libraries out of /usr/local/lib into your
project's bin directory with a make target like this:

update-libraries:
	cp `pkg-config --variable=Libraries mobjc` bin
	cp `pkg-config --variable=Libraries mcocoa` bin
	
You'll also need to ensure that pkg-config can find the pc files in /usr/lib. To 
do this you can add a line like export PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/local/lib/pkgconfig" 
to your ~/.bash_profile script.

EXAMPLES

The examples are built just like regular applications. So, you need to make sure
mobjc and mcocoa are installed and then navigate to an example directory and
execute `make update-libraries` and `make app` (or `make run`). 
	
USAGE

In general using mcocoa is very much like using Cocoa natively with reference
counting enabled. In particular memory management is the same so if you call a 
method whose name begins with "alloc" or "new" or contains "copy" then you are 
responsible for releasing its reference count.

Note however that if you use a method which takes an Objective-C block you will
need to keep the associated MObjc.ExtendedBlock object around if the lifetime of
the block is longer than the method call. For example, if you call 
beginSheetModalForWindow_completionHandler then you should save the
ExtendedBlock object it returns in a field and null it out in the completion handler.

The Cocoa wrappers are generated when you build mcocoa. The wrappers contain
all of the Cocoa methods except for a few which are variadic or use function pointers.
The methods have the same name as the native methods except colons are replaced
with underscores and the last colon is dropped (so "archiveRootObject:toFile:" becomes
"archiveRootObject_toFile"). If the name conflicts with a C# keyword it is appended
with an underscore.

mcocoa currently only ships with wrappers for Foundation and AppKit. If you want
to use another framework you can do so with dynamic calls (NSObject.Call) or build
custom C# wrappers. The quartz-chart example illustrates both of these techniques.

If you generate the library for Snow Leopard and want your app to work on earlier
versions of the OS you'll probably have to use some deprecated methods. These
will be decorated with ObsoleteAttribute in mcocoa so you'll probably want to add
a line like the below to the relevant files:
	#pragma warning disable 618

See <http://code.google.com/p/mcocoa/w/list> for more usage notes and API
References.

jesse9jones@gmail.com

About

Automatically exported from code.google.com/p/mcocoa

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published