試しに一つ設定を追加してみる。
InterfaceBuilderへラベルとポップアップボタンを配置し、NSUserDefaultsControllerへ接続するたけでユーザインターフェイスはできあがり。
コードでは SimpleCap内でファイル保存を担当する FileManagerクラスに手を入れる。
FileManager.m
- (void)saveImage:(NSBitmapImageRep*)bitmap_rep
{
int image_format_tag = [[[[NSUserDefaultsController
sharedUserDefaultsController] values]
valueForKey:@"image_format"] intValue];
NSData* data;
switch (image_format_tag) {
case 1:
// GIF
data = [bitmap_rep representationUsingType:NSGIFFileType
properties:[NSDictionary dictionary]];
break;
case 2:
// JPEG
data = [bitmap_rep representationUsingType:NSJPEGFileType
properties:[NSDictionary dictionary]];
break;
case 0:
defaults:
// PNG
data = [bitmap_rep representationUsingType:NSPNGFileType
properties:[NSDictionary dictionary]];
break;
}
[data writeToFile:[self nextFilename] atomically:YES];
}
"image_format" という名前で NSUserDefaultsから値を取り出して利用する。
PNG形式。ブログの画像では分かりづらいが影の部分はアルファチャネルが保存されいる。

JPEG形式。背景が白色となっている。

GIF形式。影の部分が真っ黒になってしまった。

- - - -
GIFの問題はあるが、環境設定はこんな感じで使っていけることがわかった。
どしどし追加していこう。