2012-11-12 25 views
1

我試圖在Xcode中修改Quicksilverplugin(屏幕截圖),以便將screencapture目標路徑設置爲默認值com.apple.screencapture路徑值。由於某種原因,該插件目前具有硬編碼路徑,因此即使您更改了屏幕截圖的OSX默認路徑,該插件仍會將它們發送到OSX默認值,即桌面。OSX Quicksilver插件,Objective C指導

我是Xcode/Objective C的字面noob,所以任何信息/示例或點在正確的方向將非常感激。

這需要進行調整的抓屏插件文件是「QSScreenCapturePlugIn.m」文件 - 這裏有一個片段:

(QSObject *)captureRegion:(QSObject *)dObject{ 

    NSString *destinationPath=[@"~/Desktop/Picture.png" stringByStandardizingPath]; 

    destinationPath=[destinationPath firstUnusedFilePath]; 

    NSTask *task=[NSTask launchedTaskWithLaunchPath:SCTOOL arguments:[NSArray arrayWithObjects:@"-is",destinationPath,nil]]; 

    [task waitUntilExit]; 

    [[QSReg preferredCommandInterface] selectObject:[QSObject fileObjectWithPath:destinationPath]]; 

    [[QSReg preferredCommandInterface] actionActivate:nil]; 
    return nil; 
} 

我已經搜查高和低的例子演示瞭如何從默認數據庫中讀取,但似乎信息稀少。

謝謝!

回答

1

我不能相信沒有人能夠用這個答案或指針來幫忙(或者我只是沒有耐心),但是幸運的是,我能夠通過其他人閱讀時找到答案在這裏的答案 - 遺憾的是我不能在這裏引用這個問題,因爲我失去了頁面。

無論如何,這將做到這一點:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 

NSString *screenCaptureLocationString = [[defaults persistentDomainForName:@"com.apple.screencapture"] valueForKey:@"location"]; 

令人驚訝的是很難找到某種原因這個信息,但希望在這裏張貼這將幫助別人。