我的应用程序中有以下保存面板。我最近尝试将其沙盒化,但不幸的是,沙盒化保存似乎不起作用。
我知道 beginSheetForDirectory 已贬值,所以可能这就是它不起作用的原因?我怎样才能让它与沙盒一起工作?
- (IBAction)saveButtonPressed:(id)sender
{
NSSavePanel *sp = [NSSavePanel savePanel];
[sp setRequiredFileType:@"jpg"];
[sp beginSheetForDirectory:[NSString stringWithFormat:@"%@/Pictures", NSHomeDirectory()]
file:@"output.jpg"
modalForWindow:window
modalDelegate:self
didEndSelector:@selector(didEndSaveSheet:returnCode:conextInfo:)
contextInfo:nil];
}
-(void)didEndSaveSheet:(NSSavePanel *)savePanel
returnCode:(int)returnCode conextInfo:(void *)contextInfo
{
if (returnCode == NSOKButton)
{
self.baseFilename = [[savePanel filename] stringByDeletingPathExtension];
tileHeight = [heightTextField intValue];
tileWidth = [widthTextField intValue];
[self performSelector:@selector(delayPresentSheet) withObject:nil afterDelay:0.1];
}
}