我基本上不了解目标c,但是我如何制作一个if语句来查看SourceTypeString是否等于1或2?
NSString* sourceTypeString = [arguments objectAtIndex:2];
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; // default
NSLog(@"my ns string = %@",sourceTypeString);
//NEWBIE PART
if ((sourceTypeString == 1))
{
NSLog(@"equals 1");
sourceType = (UIImagePickerControllerSourceType)[sourceTypeString intValue];
} else {
NSLog(@"equals 2");
sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
//NEWBIE PART
Run Code Online (Sandbox Code Playgroud)
我的代码崩溃并给了我
my ns string = 1
(lldb)
sourceTypeString __NSCFNumber * 0x0013bf80 (int)1
Run Code Online (Sandbox Code Playgroud)