macro을 이용하여 애플 제품 기기 확인하는 방법
XCode을 이용하여 프로그램중 해당 기기에 맞게 자동으로 연결해주는 메크로가 존재합니다.
이것을 이용하여 해당정보을 얻어 올 수 있습니다.
// Simple macro distinguishes iPhone from iPad
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
- (UIViewController*) helloController
{
UIViewController *vc = [[UIViewController alloc] init];
vc.view.backgroundColor = [UIColor greenColor];
// Add a basic label that says "Hello World"
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, window.bounds.size.width, 80.0f)];
label.text = @"Hello World";
label.center = CGPointMake(CGRectGetMidX(window.bounds), CGRectGetMidY(window.bounds));
label.textAlignment = UITextAlignmentCenter;
label.font = [UIFont boldSystemFontOfSize:IS_IPHONE ? 32.0f : 64.0f];
label.backgroundColor = [UIColor clearColor];
[vc.view addSubview:label];
return vc;
}