Aperture Plugin: Adding Basic Code

cocoasmall
The template code in Random_Wok.m comes with some placeholders and empty methods that need to be modified slightly. By pressing control / (forward slash) I can skip to the next placeholder. The first code it finds looks like this:
rwok7
I have to replace that with YES or NO depending on what behavior I want. In this case I want NO because I will not be supplying a list of presets:
rwok8
I return YES for -allowsMasterExport and -allowsVersionExport because initially I don't care about the file format or contents, just the file name. For -wantsFileNamingControls I return NO. I'm going to set the name myself. For -wantsDestinationPathPrompt I return YES, since I want the user to supply that. And because the user supplies that, -destinationPath can return nil.

I do need to return a value for -defaultDirectory. I'm going to return the user's Documents folder by putting this code in:
rwok9

This method is called when the user clicks the Export button. So I just tell the export manager to start the export:

rwok11
When the export manager is ready to start the export it calls the -exportManagerWillBeginExportToPath: method and provides the folder path. That folder path will need the file name appended later. So I make a copy of that path in an ivar that I create:
rwok12
Since I will be exporting all the images, this method always returns YES:
rwok13
Confirmation comes back that the image will be exported. I don't need to know this, so I ignore it:
rwok14
This method returns NO because I want to pretend that the plug-in wrote the image data somewhere. Instead I will just log what it did:
rwok15
I have to tell the export manager that the export is done if the user cancels or if the export completes:
rwok16
And that is it for now. What this should do is to give me a dialog that lets me select the export preset and whether I want the master or the version exported. Then I should get a dialog to select a destination folder that defaults to me Documents folder. When I click Export it will do nothing except log the image indexes and file names.

I compile it and there are no errors. A miracle! Here is the bundle in the Random Wok/build/Release folder:
rwok21
The other parts of this series can be found via the Cocoa page.
The Bagelturf site welcomes Donations of any size