所以我只是一起绕过了 NSSavePanel 并直接进入了 GCImageDest:
- (IBAction)saveWithNoPanel: (id)sender
{
_saveOptions = [[IKSaveOptions alloc] initWithImageProperties: _imageProperties
imageUTType: _imageUTType];
NSString * url=[[NSUserDefaults standardUserDefaults] objectForKey:@"photoPath"];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy"];
NSString * yearString = [formatter stringFromDate:[NSDate date]];
NSString * fileName = [[_imageWindow representedFilename] lastPathComponent];
//NSLog(@"Filename: %@",fileName);
NSString * photoUrl =[NSString stringWithFormat:@"%@%@%@%@%@",url,@"/",yearString,@"/",fileName];
//NSLog(@"photourl: %@",photoUrl);
NSString * newUTType = [_saveOptions imageUTType];
CGImageRef image;
image = [_imageView image];
if (image)
{
NSURL * url =[NSURL fileURLWithPath: photoUrl];
//NSLog(@"URL: %@",url);
CGImageDestinationRef dest = CGImageDestinationCreateWithURL((CFURLRef)url,
(CFStringRef)newUTType, 1, NULL);
if (dest)
{
CGImageDestinationAddImage(dest, image,
(CFDictionaryRef)[_saveOptions imageProperties]);
CGImageDestinationFinalize(dest);
CFRelease(dest);
}
} else
{
NSLog(@"*** saveImageToPath - no image");
}
[pwPhotoPathTextField setStringValue:[NSString stringWithFormat:@"%@%@",photoUrl]];
[_imageWindow orderOut:self];
}