0
votes

I made a test app for taking photos using a camera button. I'm testing on a simulator, so i cannot take snapshots. But i have created an IBAction method which when called, allows the user to select a pic from the photo library. This is the method:-

   - (IBAction)takePicture:(id)sender {
            NSLog(@"Camera button tapped");
           UIImagePickerController *imagePicker= [[UIImagePickerController alloc] init];
              if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])   {
                  NSLog(@"Yes. The Camera is available");
                  [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];

               }
               else{
                 NSLog(@"The Camera isn't available. Try thru the Photo Library");
                [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
               }
            imagePicker.allowsEditing=YES;
            [imagePicker setDelegate:self];

            NSLog(@"Presenting Modal Controller");
            [self presentViewController:imagePicker animated:YES completion:NULL];

         }

In the above scenario, when the method is called (that is when i tap the camera bar button item),the console does not log Camera button tapped message as well as Presenting Modal Controller message.All the other appropriate NSLog messages are being logged as they should be. I don't understand how come the runtime not execute these NSLog lines. There's a similar problem in -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info that i face. Here's the implementation—

     -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
           NSLog(@"imagePicker called");
           NSString *oldKey= _item.imageKey;
           if (oldKey) {
              NSLog(@"Deleting image having key- %@",oldKey);
              [[BNRImageStore sharedStore] deleteImageForKey:oldKey];
           }

          UIImage *image= [info objectForKey:UIImagePickerControllerEditedImage];

          CFUUIDRef newUniqueID= CFUUIDCreate(kCFAllocatorDefault);
          CFStringRef newUniqueIDString= CFUUIDCreateString(kCFAllocatorDefault, newUniqueID);

          //Use that uniqueID to set our item's imageKey
          NSString *key= (__bridge NSString *)newUniqueIDString;
          _item.imageKey=key;

          //Store image in the BNRImageStore with this key
          NSLog(@"putting %@ in dictionary table",_item.imageKey);
          [[BNRImageStore sharedStore] setImage:image forKey:_item.imageKey];

          //Releasing Core-Foundation objects
           CFRelease(newUniqueIDString);
           CFRelease(newUniqueID);

           [imageView setImage:image];
           NSLog(@"Dismissing Modal Controller");
           [self dismissViewControllerAnimated:YES completion:NULL];
   }

Here. the NSLog messages— imagePicker called and in the third last line— Dismissing Modal Controller are not showing up in the console. Again the runtime doesnt process these NSLog lines.

Am i assuming something wrong, because this behavior is so very weird. What's happening?

2
This sounds like a derived data problem. Try deleting your derived data and doing a clean buildJames Webster
What exactly is a derived data??rahulbsb
Is it safe to delete contents of that specific folder?? What will it do?rahulbsb
other than NSLog .. is your app functionality working fine? few statements like NSLog (in editoe), PO(Console), P(Console) will not work some time, some time these will show wrong values also. functionality is working fine then try to show alert instead of NSLog and check.Charan Giri
Derived data is the indexed information for your project. Deleting it forces XCode to reindex your project.James Webster

2 Answers

0
votes

Check this line of code below:-

#define NSLog if(0) NSLog

If it is mention 0 then your nslog statement will not execute. So make it 1 and check

#define NSLog if(1) NSLog
0
votes
 other than NSLog .. is your app functionality working fine? few statements like NSLog (in   editoe), PO(Console), P(Console) will not work some time, some time these will show wrong values also. functionality is working fine then try to show alert instead of NSLog and check.

Try using the instead of NSLog and check.

#ifdef DEBUG
#define ALog( s, ... ) NSLog( @"\n\n************************ DEBUG ***********************\n Class&method: %@,\n Line of Code: %d\n element Info: %@\n******************************************************************\n\n",  \

[[NSString stringWithUTF8String:FUNCTION] lastPathComponent], LINE, \ [NSString stringWithFormat:(s), ##VA_ARGS] );

#else #define ALog(...) #endif

use just like NSLog ex: ALog(@"log is placed");