У меня есть метод, который является простым и довольно продвинутым. Предполагается создать папку, если она не существует. Он принимает один строковый параметр, который правильно объявлен.параметр не получен в методе
Когда я использую его и передаю параметр, принимающая переменная остается пустой, что довольно странно, потому что pathTo_Folder - это путь.
Любые идеи, почему это происходит?
//Declaration in .h
- (void) createFolder : (NSString *) thePath ;
//The call
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSString *homePath = [@"~" stringByExpandingTildeInPath];
NSString *pathTo_Folder = [NSString stringWithFormat:@"%@/Library/Application Support/prolog/",homePath];
[self createFolder : pathTo_Folder];
}
//In .m
- (void) createFolder: thePath {
BOOL isDir;
NSFileManager *fileManager = [NSFileManager defaultManager] ;
[fileManager fileExistsAtPath:thePath isDirectory: &isDir] ;
NSLog(@"Folder '%@' exists: %d",thePath,isDir) ;
if (isDir == FALSE)
{
[fileManager createDirectoryAtPath: thePath withIntermediateDirectories:YES attributes:nil error:nil];
}
}
Не думаете ли вы 'thePath' должны иметь тип? –