피연산자의 데이터 형식을 문자열로 반환하다. 기본 타입과 함수는 각 타입을 식별하는 고유의 문자열을 반환하지만, 배열을 포함한 모든 객체들 'object' 문자열을 반환한다. 때문에, 객체 간의 타입 비교는 사실상 불가능하다.
해당 변수가 객체인지 기본 타입인지를 식별하고자 할 때 사용하며, 객체 간의 타입 비교를 위해서는 instanceof 연산자나 constructor 프로퍼티를 사용하면 된다.
#import <UIKit/UIKit.h> #import "ZBarReaderViewController.h" @interface BarcodeController : ZBarReaderViewController @end
#import <UIKit/UIKit.h> #import "ZBarReaderViewController.h" @interface ViewController : UIViewController <ZBarReaderDelegate> @end
#import "ViewController.h" #import "BarcodeController.h" @interface ViewController () - (void)scan:(id)sender; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; UIButton *scanButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [scanButton addTarget:self action:@selector(scan:) forControlEvents:UIControlEventTouchUpInside]; [scanButton setTitle:@"SCAN" forState:UIControlStateNormal]; scanButton.frame = CGRectMake(20.0, 40.0, 280.0, 35.0); [self.view addSubview:scanButton]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } @end
#pragma mark - Private methods - (void)scan:(id)sender { BarcodeController *barcodeController = [[[BarcodeController alloc] init] autorelease]; barcodeController.readerDelegate = self; [self presentViewController:barcodeController animated:YES completion:nil]; }
#pragma mark - ZBarReaderController methods - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { id<NSFastEnumeration> scanResults = [info objectForKey:ZBarReaderControllerResults]; NSString *result; ZBarSymbol *symbol; for (symbol in scanResults) { result = [symbol.data copy]; break; } NSLog(@"Result : %@", result); [result release]; [self dismissViewControllerAnimated:YES completion:nil]; } - (void)imagePickerControllerDidCancel: (UIImagePickerController *)picker { [self dismissViewControllerAnimated:YES completion:nil]; }
#define IS_IPHONE ( [[[UIDevice currentDevice] model] isEqualToString:@"iPhone"] ) #define IS_IPOD ( [[[UIDevice currentDevice ] model] isEqualToString:@"iPod touch"] ) #define IS_HEIGHT_GTE_568 [[UIScreen mainScreen ] bounds].size.height >= 568.0f #define IS_IPHONE_5 ( IS_IPHONE && IS_HEIGHT_GTE_568 )
defaults write com.apple.Finder AppleShowAllFiles YESFinder 강제 종료 후 재실행이 필요하다.