Tag Archives: OC

[부사리]OC-NSHost – 컴퓨터 정보가져오기

[code] int main(int argc, const char * argv[]) { @autoreleasepool { NSHost *host = [NSHost currentHost]; NSLog(@”내 컴퓨터 정보는 %@”, host); NSString *localizedName = [host localizedName]; NSLog(@”내 컴퓨터 이름은 %@”, localizedName); } return 0; } [/code]

[부사리]OC-NSDate-특정날짜 지난시간 계산

[code] int main(int argc, const char * argv[]) { @autoreleasepool { NSDateComponents *comps = [[NSDateComponents alloc] init]; [comps setYear:2005]; [comps setMonth:01]; [comps setDay:01]; [comps setHour:01]; [comps setMonth:01]; [comps setSecond:01]; NSCalendar *g = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDate *dateOfbirth = [g dateFromComponents:comps]; NSDate *now = [NSDate date]; double d = [now timeIntervalSinceDate:dateOfbirth]; NSLog(@”지난 시간 %f”, d); }… Read More »