Browsing articles tagged with " Apple"
Sep
15

Ping

With the launch of iTunes 10, Apple has launched it’s first social network aimed toward music lovers. They call it “Ping”. read more

Aug
30

Want to make iOS beta distribution easy?

Then check out iOS Beta Builder… read more

Jul
8

Help us get international promo codes

Update: Apple has responded to our pleas and implemented this feature. Thanks to everyone who duplicated my bug and helped make this happen! read more

Jun
7

iPhone 4 announced at WWDC 2010

Announced at WWDC 2010 by Steve Jobs today and making it’s way to Ireland in July, is the new iPhone 4. read more

Apr
13

Opera Mini is approved

I didn’t think we would see this, but Opera Mini is now available for free in the App Store. read more

Mar
18

Accessing Cocoa Frameworks from Java

For a long time, I searched for a way to access the Mac OS X Address Book framework from Java. This can be easily done by importing a few of the com.apple Java libraries, however, this will break the cross platform nature of your code as those libraries are not available on Windows and Linux platforms.

Recently I stumbled upon an alternative solution.

Enter, the ‘Rococoa‘ framework, which magically uses JNI to allow access to underlying Cocoa libraries.

Rococoa is a generic Java binding to the Mac Objective-C object system. It allows the creation and use of Objective-C objects in Java, and the implementation of Objective-C interfaces in Java.

For example, for class ABPerson, we can simply create the following Java class:

You can see from above, any methods that I need from this class are declared as public abstract methods.

Do the same for class ABAddressBook. Now we can start to access contacts!

First we load the native library ‘AddressBook’

Then we get a handle on the Address Book shared instance, and end up with an array of people objects.

Now we loop through all the contacts

Cast the ABPerson object

Now we can get the properties of the record!

Overall, this fantastic tool gives allows Java developers to access virtually anything that you can access from a native Objective-C XCode project. And although it may not be the most elegant solution, it works quite well for most of us!

Let me know what you think in the comments below.

Cheers,

Finbarr