ca.weblite.objc.util.CocoaUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-objc-bridge Show documentation
Show all versions of java-objc-bridge Show documentation
A thin bridge that allows for two-way communication from Java to Objective-C.
package ca.weblite.objc.util;
import ca.weblite.objc.NSObject;
import static ca.weblite.objc.RuntimeUtils.sel;
import ca.weblite.objc.annotations.Msg;
/**
* CocoaUtils class.
*
* @author shannah
* @version $Id: $Id
* @since 1.1
*/
public class CocoaUtils {
/**
* dispatch_async.
*
* @param r a {@link java.lang.Runnable} object.
*/
public static void dispatch_async(final Runnable r){
(new NSObject("NSObject"){
@Msg(selector="run", like="NSObject.finalize")
public void run(){
r.run();
}
}).send("performSelectorOnMainThread:withObject:waitUntilDone:", sel("run"), null, false);
}
/**
* dispatch_sync.
*
* @param r a {@link java.lang.Runnable} object.
*/
public static void dispatch_sync(final Runnable r){
(new NSObject("NSObject"){
@Msg(selector="run", like="NSObject.finalize")
public void run(){
r.run();
}
}).send("performSelectorOnMainThread:withObject:waitUntilDone:", sel("run"), null, true);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy