Foundation { public static ID cfString(String s) { try { byte[] utf16Bytes = s.getBytes("UTF-16LE"); return foundationLibrary.CFStringCreateWithBytes(null, utf16Bytes, utf16Bytes.length, StringEncoding.kCFStringEncodingUTF16LE.value, (byte) 0); } catch (UnsupportedEncodingException x) { throw new RococoaException(x); } } private  Foundation(); static void nsLog(String format, Object thing); static ID cfString(String s); static ID cfRetain(ID id); static void cfRelease(ID id); static int cfGetRetainCount(ID cfTypeRef); static String toString(ID cfString); static ID getClass(String className); static Selector selector(String selectorName); static T send(ID receiver, String selectorName, Class<T> returnType, Object... args); @SuppressWarnings("unchecked") static T send(ID receiver, Selector selector, Class<T> returnType, Object... args); static ID sendReturnsID(ID receiver, String selectorName, Object... args); static void sendReturnsVoid(ID receiver, String selectorName, Object... args); static boolean isMainThread(); static T callOnMainThread(final Callable<T> callable); static void runOnMainThread(final Runnable runnable); static void runOnMainThread(Runnable runnable, boolean waitUntilDone); static ID newOCProxy(OCInvocationCallbacks callbacks); static boolean selectorNameMeansWeOwnReturnedObject(String selectorName);  }
@Test public void testCFString() { ID string = Foundation.cfString("Hello World"); assertNotNull(string); assertEquals("Hello World", Foundation.toString(string)); }