Create an NSObject class and name it as ClsGlobal or the name you want.
then write +(BOOL)isCameraDeviceAvailable in ClsGlobal.h and execute the following function in ClsGlobal.m .
+(BOOL)isCameraDeviceAvailable { BOOL isCameraAvailable=NO; if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { if([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront] || [UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear]) isCameraAvailable = YES; } return isCameraAvailable; }
Use this class method. It will return YES if an available camera has not yet been specified.
Now you can call this method using [ClsGlobal isCameraDeviceAvailable]; means your if the Condition looks like if([ClsGlobal isCameraDeviceAvailable]) .
This method will help you throughout the project in any controller. You just need to import ClsGlobal, like #import "ClsGlobal.h" .
source share