开发者

set lastPathComponent string after save

Doc based, QTKit app. When saving, the new filename updates in the activ开发者_StackOverflow中文版e window titleBar. I would also like to display the newly saved filename string in a textField, somewhere else on the opened doc. The code successfully saves the new doc. However the lastPathComponent string doesn't update. Please advise?

thanks,

Paul

- (void)savePanelDidEnd:(NSSavePanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
  NSURL *outputFileURL = [(NSURL *)contextInfo autorelease];    



if (returnCode == NSOKButton) {
    NSString *filename = [sheet filename];

    [[NSFileManager defaultManager] moveItemAtPath:[outputFileURL path] toPath:filename error:nil];

    NSString    *path = [filename lastPathComponent];
    [textField setStringValue:[path lastPathComponent]];

    [[NSWorkspace sharedWorkspace] openFile:filename];
} 


else {
    [[NSFileManager defaultManager] removeItemAtPath:[outputFileURL path] error:nil];


}

}


Since "filename" is apparently valid (because things are working and your window title updates), have you checked to make sure "textField" is actually connected in your XIB?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜