org.rococoa
Class Rococoa

java.lang.Object
  extended by org.rococoa.Rococoa

public abstract class Rococoa
extends Object

Static factory for creating Java wrappers for Objective-C instances, and Objective-C wrappers for Java instances. START HERE.

Author:
duncan

Nested Class Summary
static class Rococoa.ProxyID
           
 
Method Summary
static
<T extends ObjCObject>
T
cast(ObjCObject object, Class<T> desiredType)
          Create a Java NSObject down-casting an existing NSObject to a more derived type.
static
<T extends ObjCObject>
T
create(String ocClassName, Class<T> javaClass)
          Create a Java NSObject representing an instance of the Objective-C class ocClassName, created with the class method +new.
static
<T extends ObjCObject>
T
create(String ocClassName, Class<T> javaClass, String ocMethodName, Object... args)
          Create a Java NSObject representing an instance of the Objective-C class ocClassName.
static
<T extends ObjCClass>
T
createClass(String ocClassName, Class<T> type)
          Create a Java NSClass representing the Objective-C class with ocClassName
static ObjCObject proxy(Object javaObject)
          Return a new Objective-C object that will forward messages to javaObject, for use in delegates, notifications etc.
static
<T extends ObjCObject>
T
proxy(Object javaObject, Class<T> javaType)
           
static
<T extends ObjCObject>
T
wrap(ID id, Class<T> javaClass)
          Create a Java NSObject wrapping an existing Objective-C instance, represented by id.
static
<T extends ObjCObject>
T
wrap(ID id, Class<T> javaClass, boolean retain)
           
static ID wrap(Object javaObject)
          Deprecated. because the OC proxy object is never released. Use proxy(java.lang.Object) instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createClass

public static <T extends ObjCClass> T createClass(String ocClassName,
                                                  Class<T> type)
Create a Java NSClass representing the Objective-C class with ocClassName


create

public static <T extends ObjCObject> T create(String ocClassName,
                                              Class<T> javaClass,
                                              String ocMethodName,
                                              Object... args)
Create a Java NSObject representing an instance of the Objective-C class ocClassName. The Objective-C instance is created by calling the static factory method named ocMethodName, passing args.


create

public static <T extends ObjCObject> T create(String ocClassName,
                                              Class<T> javaClass)
Create a Java NSObject representing an instance of the Objective-C class ocClassName, created with the class method +new.


wrap

public static <T extends ObjCObject> T wrap(ID id,
                                            Class<T> javaClass)
Create a Java NSObject wrapping an existing Objective-C instance, represented by id. The NSObject is retained, and released when the object is GC'd.


cast

public static <T extends ObjCObject> T cast(ObjCObject object,
                                            Class<T> desiredType)
Create a Java NSObject down-casting an existing NSObject to a more derived type.


wrap

public static <T extends ObjCObject> T wrap(ID id,
                                            Class<T> javaClass,
                                            boolean retain)

wrap

@Deprecated
public static ID wrap(Object javaObject)
Deprecated. because the OC proxy object is never released. Use proxy(java.lang.Object) instead.

Return the ID of a new Objective-C object that will forward messages to javaObject. Keep hold of the ID all the time that methods may be invoked on the Obj-C object, otherwise the callbacks may be GC'd, with amusing consequences.


proxy

public static ObjCObject proxy(Object javaObject)
Return a new Objective-C object that will forward messages to javaObject, for use in delegates, notifications etc. You need to keep a reference to the returned value for as long as it is active. When it is GC'd, it will release the Objective-C proxy.


proxy

public static <T extends ObjCObject> T proxy(Object javaObject,
                                             Class<T> javaType)


Copyright © 2012. All Rights Reserved.