Xcode 2/Foundation
디렉토리, 사용자 정보 얻기
cocoadev
2008. 3. 7. 15:14
* NSFileManager : - (NSString *)currentDirectoryPath
어플리케이션의 현재 디렉토리를 반환합니다.
* NSBundle : - (NSString *)bundlePath
어플리케이션의 번들 디렉토리를 반환합니다.
* NSString *NSHomeDirectory(void)
현재 사용자의 홈 디렉토리를 반환합니다.
* NSString *NSHomeDirectoryForUser(NSString *userName)
특정 계정(userName) 사용자의 홈디렉토리를 반환합니다.
* NSTemporaryDirectory()
임시(temp)로 사용할 수 있는 디렉토리를 반환합니다.
* NSString *NSUserName(void)
현재 사용자의 계정 이름을 반환합니다.
* NSString *NSFullUserName(void)
현재 사용자의 전체 이름을 반환합니다.
실행 결과는 아래와 같습니다.

어플리케이션의 현재 디렉토리를 반환합니다.
* NSBundle : - (NSString *)bundlePath
어플리케이션의 번들 디렉토리를 반환합니다.
* NSString *NSHomeDirectory(void)
현재 사용자의 홈 디렉토리를 반환합니다.
* NSString *NSHomeDirectoryForUser(NSString *userName)
특정 계정(userName) 사용자의 홈디렉토리를 반환합니다.
* NSTemporaryDirectory()
임시(temp)로 사용할 수 있는 디렉토리를 반환합니다.
* NSString *NSUserName(void)
현재 사용자의 계정 이름을 반환합니다.
* NSString *NSFullUserName(void)
현재 사용자의 전체 이름을 반환합니다.
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// insert code here...
NSLog(@"Cur Path: %@",
[[NSFileManager defaultManager] currentDirectoryPath]);
NSLog(@"Bundle Path: %@", [[NSBundle mainBundle] bundlePath]);
NSLog(@"Home Path: %@", NSHomeDirectory());
NSLog(@"User Home Path: %@",
NSHomeDirectoryForUser(NSUserName()));
NSLog(@"Temp Path: %@", NSTemporaryDirectory());
NSLog(@"User Name: %@", NSFullUserName());
[pool release];
return 0;
}
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// insert code here...
NSLog(@"Cur Path: %@",
[[NSFileManager defaultManager] currentDirectoryPath]);
NSLog(@"Bundle Path: %@", [[NSBundle mainBundle] bundlePath]);
NSLog(@"Home Path: %@", NSHomeDirectory());
NSLog(@"User Home Path: %@",
NSHomeDirectoryForUser(NSUserName()));
NSLog(@"Temp Path: %@", NSTemporaryDirectory());
NSLog(@"User Name: %@", NSFullUserName());
[pool release];
return 0;
}
실행 결과는 아래와 같습니다.
