Today I want to explain some differences between using a declare for a Cocoa function call and using MBS Plugins wrapper classes.
- You get automatic reference counting. The plugin takes care of memory management and makes sure all objects are released as appropriated.
- Our plugin keeps references between Xojo and Cocoa objects, so we can give you the same Xojo object when a function returns us a Cocoa object and we have a wrapping Xojo object already. This saves memory and makes sure that if you subclass one of our classes, you get back your subclass object and you can access your properties there.
- We catch exceptions and forward them as Xojo exceptions. See NSExceptionMBS class. We also have a global exception handler to make sure no NSException is raised without your app having a chance to handle it.
- For APIs taking blocks and getting callbacks, our plugin makes sure those get dispatched on the main thread. Often callbacks occur on helper threads and cause problems if Xojo runtime calls are executed there. The Xojo runtime is not reentrant safe.
- In most block based APIs we provide a tag parameter and also pass through most parameters. For that we properly wrap Xojo objects for you and release them later after Event is called. This makes sure that all used objects stay in memory
- For the plugin methods, we do a lot of automatic parameter conversions. e.g. you can pass folderitems and we pass internally URL or path, depending on API. We also translate dictionaries, arrays, sets, memoryblocks and structures on the fly.
- If we decide to wrap a framework for Apple, we normally do it 100%. So the wrapper should be complete and you should not be missing something.