applicationSupportDirectory

applicationSupportDirectory

AppDelegate始终有一个预编写的函数:

(NSString *)applicationSupportDirectory {

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
    NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : NSTemporaryDirectory();
    return [basePath stringByAppendingPathComponent:@"SyncFile"];
}


但是,我不能在此类之外调用此方法:

id _appDelegate = (SyncFile_AppDelegate *)[[NSApplication sharedApplication] delegate];
NSLog(@"%@", [_appDelegate applicationSupportDirectory]);


编译器警告我找不到方法applicationSupportDirectory ...
有人知道我的代码有什么问题吗?
非常感谢你!

最佳答案

别忘了#import "SyncFile_AppDelegate.h"

10-06 07:10