### Maven Build Success Output Source: https://github.com/iterate-ch/rococoa/blob/master/Building.md Example output indicating a successful Maven build and test execution. ```text Results : [surefire] Tests run: 58, Failures: 0, Errors: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1 minute 46 seconds [INFO] Finished at: Fri Feb 22 11:39:09 GMT 2008 [INFO] Final Memory: 5M/10M [INFO] ------------------------------------------------------------------------ ``` -------------------------------- ### Play Quicktime Movie with Rococoa Source: https://github.com/iterate-ch/rococoa/blob/master/Quicktime.md This example demonstrates how to play a Quicktime movie file using Rococoa. It involves setting up a movie view, loading the movie, and displaying it in a JFrame. Ensure the QTKit library is loaded. ```java public class PlayMovieExample { static final File FILE = new File("testdata/DrWho.mov"); static { // load library @SuppressWarnings("unused") QTKit instance = QTKit.instance; } public static void main(String[] args) { QTMovieView movieView = QTMovieView.CLASS.create(); movieView.setControllerVisible(true); movieView.setPreservesAspectRatio(true); MovieComponent component = new MovieComponent(movieView); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(component); QTMovie movie = QTMovie.movieWithFile_error(FILE.getPath(), null); movieView.setMovie(movie); movie.gotoBeginning(); frame.pack(); frame.setVisible(true); } } ``` -------------------------------- ### Configure Info.plist for Main Thread Start Source: https://github.com/iterate-ch/rococoa/blob/master/NIBLoading.md Add the StartOnMainThread flag to your application's Info.plist to ensure event processing on the AppKit thread. ```xml Java StartOnMainThread ``` -------------------------------- ### Play Quicktime Movie with Rococoa Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-quicktime.html This example demonstrates how to play a Quicktime movie using Rococoa. It sets up a movie view, loads a movie file, and displays it in a JFrame. Ensure the Quicktime movie file exists at the specified path. ```java public class PlayMovieExample { static final File FILE = new File("testdata/DrWho.mov"); static { // load library @SuppressWarnings("unused") QTKit instance = QTKit.instance; } public static void main(String[] args) { QTMovieView movieView = QTMovieView.CLASS.create(); movieView.setControllerVisible(true); movieView.setPreservesAspectRatio(true); MovieComponent component = new MovieComponent(movieView); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(component); QTMovie movie = QTMovie.movieWithFile_error(FILE.getPath(), null); movieView.setMovie(movie); movie.gotoBeginning(); frame.pack(); frame.setVisible(true); } } ``` -------------------------------- ### Install JNA JAR with Maven Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-building.html Installs the JNA library into the Maven repository when it's not packaged with Maven. Ensure the file path is correct. ```bash mvn install:install-file -DgroupId=net.java.dev -DartifactId=jna \ -Dversion=3.0.1 -Dpackaging=jar -Dfile=/path/to/file ``` -------------------------------- ### Initialize NSApplication and Run Event Loop Source: https://github.com/iterate-ch/rococoa/blob/master/NIBLoading.md This is the main class for a Cocoa application. It initializes NSApplication, sets up an autorelease pool, and starts the main event loop. Ensure this class is registered in your application's Info.plist. ```Java import org.rococoa.cocoa.foundation. NSAutoreleasePool; public class MainController { public static void main(String[] args) { final NSAutoreleasePool pool = NSAutoreleasePool.push(); try { // This method also makes a connection to the window server and completes other initialization. // Your program should invoke this method as one of the first statements in main(); // The NSApplication class sets up autorelease pools (instances of the NSAutoreleasePool class) // during initialization and inside the event loop—specifically, within its initialization // (or sharedApplication) and run methods. final NSApplication app = NSApplication.sharedApplication(); WindowController w = new WindowController(); // Starts the main event loop. The loop continues until a stop: or terminate: message is // received. Upon each iteration through the loop, the next available event // from the window server is stored and then dispatched by sending it to NSApp using sendEvent:. // The global application object uses autorelease pools in its run method. app.run(); } finally { pool.drain(); } } } ``` -------------------------------- ### Generate Maven Site Documentation Source: https://github.com/iterate-ch/rococoa/blob/master/Building.md Generates project documentation, including Javadoc, using Maven. ```bash mvn site ``` -------------------------------- ### Create and Populate NSMutableArray Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-whistlestop.html Demonstrates creating an NSMutableArray with a specified capacity and adding NSString and String objects. Verifies the count and description of the array. ```java public class NSMutableArrayTest extends RococoaTestCase { public void test() { NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3); assertEquals(0, array.count()); array.addObject(NSString.stringWithString("Hello")); array.addObject("Goodbye"); assertEquals(2, array.count()); assertEquals("(\n Hello,\n Goodbye\n)", array.description()); } } ``` -------------------------------- ### Build and Test Rococoa with Maven Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-building.html Builds and tests the Rococoa project using Maven. Successful builds will show a 'BUILD SUCCESSFUL' message. ```bash mvn test ``` -------------------------------- ### Create and Test NSMutableArray Instance Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-whistlestop.html Demonstrates creating an NSMutableArray instance using the Rococoa-generated CLASS object and calling the NSObject description method. Asserts the initial description of an empty array. ```java public class NSMutableArrayTest extends RococoaTestCase { public void test() { NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3); assertEquals("(\n)", array.description()); } } ``` -------------------------------- ### Common Maven Goals for Rococoa Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-building.html Lists common Maven goals for cleaning the project, generating documentation, and packaging the distribution. ```bash mvn clean ``` ```bash mvn site ``` ```bash mvn package ``` -------------------------------- ### Instantiate Objective-C Class Wrapper Source: https://github.com/iterate-ch/rococoa/blob/master/WhistlestopTour.md Create a static CLASS field to link the Java interface to the Objective-C class using Rococoa.createClass. ```java public interface NSMutableArray extends NSObject { public static final _Class CLASS = Rococoa.createClass("NSMutableArray", _Class.class); public interface _Class extends NSClass { NSMutableArray arrayWithCapacity(int numItems); } } ``` -------------------------------- ### Generate Eclipse Project Files with Maven Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-building.html Generates the necessary .classpath and .project files for importing the Rococoa project into an Eclipse workspace. Ensure the M2_REPO classpath variable is set correctly in Eclipse. ```bash mvn eclipse:eclipse ``` -------------------------------- ### Create and Release Autorelease Pool in Java Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-memory.html Demonstrates how to create an autorelease pool using Foundation.createPool() and release it with Foundation.releasePool(). This is essential before invoking Objective-C methods that require memory allocation. ```Java public void runBare() throws Throwable { pool = Foundation.createPool(); try { super.runBare(); } finally { Foundation.releasePool(pool); } } ``` -------------------------------- ### Package Maven Project Distribution Source: https://github.com/iterate-ch/rococoa/blob/master/Building.md Packages the Rococoa project into a distribution archive. ```bash mvn package ``` -------------------------------- ### WindowController Class for NIB Loading Source: https://github.com/iterate-ch/rococoa/blob/master/NIBLoading.md Implement a WindowController to load a NIB file and act as its file owner. Ensure you maintain a reference to the proxy object to prevent premature garbage collection. ```java import org.rococoa.ID; import org.rococoa.NSObject; import org.rococoa.Rococoa; public class WindowController { public WindowController() { String bundleName = "MyNib" // Load the NIB file and pass it our Rococoa proxy as the file owner. if(!NSBundle.loadNibNamed(bundleName, this.id())) { System.err.println("Couldn't load " + bundleName + ".nib"); return; } } // Injected outlet from NIB private NSWindow window; // Called when loading NIB using NSBundle. NIB has a mainWindow outlet defined. public void setMainWindow(NSWindow mainWindow) { System.out.println("Outlet set to: " + mainWindow.title()); } // NSButton in NIB has an action to the file owner named buttonClicked: public void buttonClicked(ID sender) { System.out.println("Hello World from: " + sender); } /** * You need to keep a reference to the returned value for as long as it is * active. When it is GCd, it will release the Objective-C proxy. */ private NSObject proxy; private ID id; public NSObject proxy() { return this.proxy(NSObject.class); } public NSObject proxy(Class type) { if(null == proxy) { proxy = Rococoa.proxy(this, type); } return proxy; } public org.rococoa.ID id() { return this.id(NSObject.class); } public org.rococoa.ID id(Class type) { if(null == id) { id = this.proxy(type).id(); } return id; } } ``` -------------------------------- ### Maven Repository Configuration Source: https://github.com/iterate-ch/rococoa/blob/master/README.md Configure your project's POM to reference Rococoa artifacts from the S3-hosted repository. ```xml maven.cyberduck.io-release https://s3.eu-west-1.amazonaws.com/repo.maven.cyberduck.io/releases default true false ``` -------------------------------- ### Rococoa Core and Librococoa Dependencies Source: https://github.com/iterate-ch/rococoa/blob/master/README.md Add the core Rococoa library and the native librococoa dynamic library to your project's dependencies. ```xml org.rococoa rococoa-core 0.9.1 org.rococoa librococoa 0.9.1 dylib runtime ``` -------------------------------- ### Retrieving Objects from NSMutableArray by Index Source: https://github.com/iterate-ch/rococoa/blob/master/WhistlestopTour.md Demonstrates retrieving objects from an NSMutableArray using objectAtIndex and comparing them. ```Java public interface NSMutableArray extends NSObject { public static final _Class CLASS = Rococoa.createClass("NSMutableArray", _Class.class); public interface _Class extends NSClass { NSMutableArray arrayWithCapacity(int numItems); } int count(); void addObject(NSObject anObject); void addObject(String string); *String objectAtIndex(int index);* } public class NSMutableArrayTest extends RococoaTestCase { public void test() { NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3); assertEquals(0, array.count()); array.addObject(NSString.stringWithString("Hello")); array.addObject("Goodbye"); assertEquals(2, array.count()); *String first = array.objectAtIndex(0); assertEquals("Hello", first); assertEquals("Goodbye", array.objectAtIndex(1));* } } ``` -------------------------------- ### Instantiate Objective-C Class Wrapper with Rococoa Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-whistlestop.html Use Rococoa.createClass to obtain an instance of the nested _Class interface, which allows calling Objective-C static methods. This requires specifying the Objective-C class name and the Java wrapper class. ```java public interface NSMutableArray extends NSObject { public static final _Class CLASS = Rococoa.createClass("NSMutableArray", _Class.class); public interface _Class extends NSClass { NSMutableArray arrayWithCapacity(int numItems); } } ``` -------------------------------- ### Test NSMutableArray Creation and Description Source: https://github.com/iterate-ch/rococoa/blob/master/WhistlestopTour.md Test the creation of an NSMutableArray instance and call its description method. ```java public class NSMutableArrayTest extends RococoaTestCase { public void test() { NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3); assertEquals("( )", array.description()); } } ``` -------------------------------- ### Test NSMutableArray addObject and Description Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-whistlestop.html Tests adding a NSString to the NSMutableArray and verifies the count and description. Demonstrates Rococoa's special handling of Java Strings to NSString conversion. ```java public class NSMutableArrayTest extends RococoaTestCase { public void test() { NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3); assertEquals(0, array.count()); NSString aString = NSString.stringWithString("Hello")); array.addObject(aString); assertEquals(1, array.count()); assertEquals("(\n Hello\n)", array.description()); } } ``` -------------------------------- ### Casting Retrieved NSObject to NSString Source: https://github.com/iterate-ch/rococoa/blob/master/WhistlestopTour.md Demonstrates casting an retrieved NSObject to NSString using Rococoa.cast and comparing its string value. ```Java public class NSMutableArrayTest extends RococoaTestCase { public void test() { NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3); assertEquals(0, array.count()); array.addObject(NSString.stringWithString("Hello")); array.addObject("Goodbye"); assertEquals(2, array.count()); NSObject first = array.objectAtIndex(0); assertEquals(NSString.stringWithString("Hello"), first); *NSString firstAsString = Rococoa.cast(first, NSString.class); assertEquals("Hello", firstAsString.toString()); assertEquals("Goodbye", Rococoa.cast(array.objectAtIndex(1), NSString.class).toString());* } } ``` -------------------------------- ### Test NSMutableArray Add Object and Description Source: https://github.com/iterate-ch/rococoa/blob/master/WhistlestopTour.md Test adding an NSString to the NSMutableArray and verify the updated count and description. ```java public class NSMutableArrayTest extends RococoaTestCase { public void test() { NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3); assertEquals(0, array.count()); NSString aString = NSString.stringWithString("Hello")); array.addObject(aString); assertEquals(1, array.count()); assertEquals("( Hello )", array.description()); } } ``` -------------------------------- ### Retrieve Object from NSMutableArray Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-whistlestop.html Shows how to retrieve objects from an NSMutableArray by their index after adding them. Assumes the array returns String objects. ```java public class NSMutableArrayTest extends RococoaTestCase { public void test() { NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3); assertEquals(0, array.count()); array.addObject(NSString.stringWithString("Hello")); array.addObject("Goodbye"); assertEquals(2, array.count()); String first = array.objectAtIndex(0); assertEquals("Hello", first); assertEquals("Goodbye", array.objectAtIndex(1)); } } ``` -------------------------------- ### Clean Maven Project Source: https://github.com/iterate-ch/rococoa/blob/master/Building.md Cleans the Maven project, removing compiled files and build artifacts. ```bash mvn clean ``` -------------------------------- ### Comparing Retrieved NSObject with NSString Source: https://github.com/iterate-ch/rococoa/blob/master/WhistlestopTour.md Shows how to retrieve an NSObject from NSMutableArray and compare it with an NSString. ```Java public class NSMutableArrayTest extends RococoaTestCase { public void test() { NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3); assertEquals(0, array.count()); array.addObject(NSString.stringWithString("Hello")); array.addObject("Goodbye"); assertEquals(2, array.count()); *NSObject first = array.objectAtIndex(0); assertEquals(NSString.stringWithString("Hello"), first);* } } ``` -------------------------------- ### Retrieve NSObject from NSMutableArray Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-whistlestop.html Demonstrates retrieving objects as NSObject from an NSMutableArray, suitable for comparing with other NSObject instances. ```java public class NSMutableArrayTest extends RococoaTestCase { public void test() { NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3); assertEquals(0, array.count()); array.addObject(NSString.stringWithString("Hello")); array.addObject("Goodbye"); assertEquals(2, array.count()); NSObject first = array.objectAtIndex(0); assertEquals(NSString.stringWithString("Hello"), first); } } ``` -------------------------------- ### Cast NSObject to NSString Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-whistlestop.html Illustrates casting a retrieved NSObject from an NSMutableArray to an NSString using Rococoa.cast, then converting it to a String. ```java public class NSMutableArrayTest extends RococoaTestCase { public void test() { NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3); assertEquals(0, array.count()); array.addObject(NSString.stringWithString("Hello")); array.addObject("Goodbye"); assertEquals(2, array.count()); NSObject first = array.objectAtIndex(0); assertEquals(NSString.stringWithString("Hello"), first); NSString firstAsString = Rococoa.cast(first, NSString.class); assertEquals("Hello", firstAsString.toString()); assertEquals("Goodbye", Rococoa.cast(array.objectAtIndex(1), NSString.class).toString()); } } ``` -------------------------------- ### Adding Objects to NSMutableArray Source: https://github.com/iterate-ch/rococoa/blob/master/WhistlestopTour.md Shows how to add both NSObject and String objects to an NSMutableArray and check its count. ```Java public interface NSMutableArray extends NSObject { public static final _Class CLASS = Rococoa.createClass("NSMutableArray", _Class.class); public interface _Class extends NSClass { NSMutableArray arrayWithCapacity(int numItems); } int count(); void addObject(NSObject anObject); *void addObject(String string);* } public class NSMutableArrayTest extends RococoaTestCase { public void test() { NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3); assertEquals(0, array.count()); array.addObject(NSString.stringWithString("Hello")); *array.addObject("Goodbye"); assertEquals(2, array.count()); assertEquals("( Hello, Goodbye )", array.description());* } } ``` -------------------------------- ### Rococoa String Marshalling Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-whistlestop.html When a Java parameter is declared as java.lang.String, Rococoa automatically marshals it into an Objective-C NSString. This simplifies passing string data between Java and Objective-C. ```java public interface NSMutableArray extends NSObject { ``` -------------------------------- ### Casting objc_msgSend for Return Types Source: https://github.com/iterate-ch/rococoa/blob/master/www/objc_msgSend.html For methods returning specific types like BOOL, casting objc_msgSend to the correct function signature is necessary for cross-architecture compatibility, especially on Intel Macs. ```objc BOOL isEqual = ((BOOL (*)(id, SEL, id))objc_msgSend)(object, @selector("isEqual:"), otherString); ``` -------------------------------- ### Objective-C Runtime Function Signatures Source: https://github.com/iterate-ch/rococoa/blob/master/ObjcMsgSend.md These are the declared signatures for the core Objective-C message sending functions. Note the 'stret' variants are used for methods returning structures. ```objc id objc_msgSend(struct objc_super *super, SEL op, ...) void objc_msgSend_stret(void * stretAddr, id theReceiver, SEL theSelector, ...) ``` -------------------------------- ### NSMutableArray Interface with NSObject objectAtIndex Source: https://github.com/iterate-ch/rococoa/blob/master/WhistlestopTour.md Defines the NSMutableArray interface with an objectAtIndex method returning NSObject. ```Java public interface NSMutableArray extends NSObject { public static final _Class CLASS = Rococoa.createClass("NSMutableArray", _Class.class); public interface _Class extends NSClass { NSMutableArray arrayWithCapacity(int numItems); } int count(); void addObject(NSObject anObject); void addObject(String string); NSObject objectAtIndex(int index); } ``` -------------------------------- ### Resize Iframe JavaScript Function Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-wiki.html This JavaScript function resizes an iframe to fit the browser window height. It should be called on window resize events. ```javascript function resize_iframe() { var height=window.innerHeight; if (document.body.clientHeight) { height=document.body.clientHeight; } document.getElementById("glu").style.height=parseInt(height- document.getElementById("glu").offsetTop-8)+"px"; } ``` -------------------------------- ### Attach Resize Iframe to Window Event Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-wiki.html This line of JavaScript attaches the resize_iframe function to the window's onresize event, ensuring the iframe is resized whenever the browser window dimensions change. ```javascript window.onresize=resize_iframe; ``` -------------------------------- ### Test NSMutableArray count Method Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-whistlestop.html Tests the count method of the NSMutableArray instance created earlier. Asserts that the initial count of the array is 0. ```java public class NSMutableArrayTest extends RococoaTestCase { public void test() { NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3); assertEquals("(\n)", array.description()); assertEquals(0, array.count()); } } ``` -------------------------------- ### Add Objective-C Class Method Wrapper to Java Interface Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-whistlestop.html To call Objective-C class (static) methods, define a nested interface (conventionally named _Class) within the Java interface. Add methods to this nested interface that mirror the Objective-C method signatures. ```java public interface NSMutableArray extends NSObject { public interface _Class extends NSClass { NSMutableArray arrayWithCapacity(int numItems); } } ``` -------------------------------- ### Add NSArray count Method to Java Interface Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-whistlestop.html Extend the Java interface to include methods from Objective-C's NSArray, such as count. This allows calling instance methods on the Objective-C object from Java. ```java public interface NSMutableArray extends NSObject { public static final _Class CLASS = Rococoa.createClass("NSMutableArray", Class.class); public interface _Class extends NSClass { NSMutableArray arrayWithCapacity(int numItems); } int count(); } ``` -------------------------------- ### Define NSMutableArray Interface Source: https://github.com/iterate-ch/rococoa/blob/master/WhistlestopTour.md Define a Java interface for the Objective-C NSMutableArray class, extending NSObject. ```java public interface NSMutableArray extends NSObject { } ``` -------------------------------- ### Add Class Method Wrapper for NSMutableArray Source: https://github.com/iterate-ch/rococoa/blob/master/WhistlestopTour.md Add a nested _Class interface to handle Objective-C class methods like arrayWithCapacity. ```java public interface NSMutableArray extends NSObject { public interface _Class extends NSClass { NSMutableArray arrayWithCapacity(int numItems); } } ``` -------------------------------- ### Test NSMutableArray Count Source: https://github.com/iterate-ch/rococoa/blob/master/WhistlestopTour.md Test the count method of the NSMutableArray instance. ```java public class NSMutableArrayTest extends RococoaTestCase { public void test() { NSMutableArray array = NSMutableArray.CLASS.arrayWithCapacity(3); assertEquals(0, array.count()); } } ``` -------------------------------- ### Casting objc_msgSend_stret for Struct Returns Source: https://github.com/iterate-ch/rococoa/blob/master/ObjcMsgSend.md Demonstrates the correct way to cast objc_msgSend_stret to a function pointer that returns the expected struct type. This ensures the compiler generates the correct stack cleanup code. ```objc NSRect (*msgSend_stret_fn)(id, SEL, ...) = (NSRect(*)(id, SEL, ...))objc_msgSend_stret; NSRect result = (*msgSend_stret_fn)(myNSView, @selector(frame)); ``` ```objc NSRect result = (*(NSRect(*)(id, SEL, ...))objc_msgSend_stret)(myNSView, @selector(frame)); ``` -------------------------------- ### Add addObject Method to Java Interface Source: https://github.com/iterate-ch/rococoa/blob/master/www/rococoa-whistlestop.html Include the addObject method in the Java interface to allow adding NSObject instances to the NSMutableArray. The Objective-C (id) parameter maps to Java's NSObject. ```java public interface NSMutableArray extends NSObject { public static final _Class CLASS = Rococoa.createClass("NSMutableArray", _Class.class); public interface _Class extends NSClass { NSMutableArray arrayWithCapacity(int numItems); } int count(); void addObject(NSObject anObject); } ``` -------------------------------- ### Add count Method to NSMutableArray Interface Source: https://github.com/iterate-ch/rococoa/blob/master/WhistlestopTour.md Add the Objective-C count method to the Java interface to retrieve the number of elements. ```java public interface NSMutableArray extends NSObject { public static final _Class CLASS = Rococoa.createClass("NSMutableArray", Class.class); public interface _Class extends NSClass { NSMutableArray arrayWithCapacity(int numItems); } int count(); } ``` -------------------------------- ### Casting objc_msgSend_stret for Struct Returns Source: https://github.com/iterate-ch/rococoa/blob/master/www/objc_msgSend.html When a method returns a struct, objc_msgSend_stret is used. To ensure correct handling, cast the function pointer to a function that returns the specific struct type. ```objc NSRect ( *msgSend_stret_fn)(id, SEL, ...) = (NSRect(*)(id, SEL, ...))objc_msgSend_stret; NSRect result = (*msgSend_stret_fn)(myNSView, @selector(frame)); ``` ```objc NSRect result = (*(NSRect(*)(id, SEL, ...))objc_msgSend_stret)(myNSView, @selector(frame)); ``` -------------------------------- ### Add addObject Method to NSMutableArray Interface Source: https://github.com/iterate-ch/rococoa/blob/master/WhistlestopTour.md Add the Objective-C addObject method to the Java interface to add an NSObject to the array. ```java public interface NSMutableArray extends NSObject { public static final _Class CLASS = Rococoa.createClass("NSMutableArray", _Class.class); public interface _Class extends NSClass { NSMutableArray arrayWithCapacity(int numItems); } int count(); void addObject(NSObject anObject); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.