Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Caleb Kleveter
Treehouse Moderator 37,862 PointsDoes !truefalse exist in Obj-C?
I saw some code that a person on Stack Overflow posted and it used
!truefalse
in it, is it a bug?
2 Answers
Gabe Nadel
Treehouse Guest TeacherCaleb,
What is !truefalse supposed to do? Does it exist in another language, if so, what does it do?
Perhaps they just created a Bool called "truefalse"?
If you link to the post I can take a peek.
Thanks!
Caleb Kleveter
Treehouse Moderator 37,862 PointsWhat you said about a bool being created with that name makes sense. I put arrows on the lines with it. Here is the link to the SO post.
-(BOOL) launchCameraControllerFromViewController: (UIViewController*) controller usingDelegate: (id <UIImagePickerControllerDelegate, UINavigationControllerDelegate>)
===> BOOL truefalse = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
//variable to check whether there is a camera available
//if there is a camera, the delegate passed exists, and the controller passed exists, proceed on, otherwise don't go any further
On this line ===> if (!truefalse || (delegate == nil) || (controller == nil)) {
NSLog(@"no can do, delegate/camera/view controller doesn't exist!");
return NO;
}
UIImagePickerController *cameraController = [[UIImagePickerController alloc] init];
cameraController.sourceType = UIImagePickerControllerSourceTypeCamera;
cameraController.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
cameraController.allowsEditing = NO;
cameraController.delegate = delegate;