-2

I have got this error on the line where the void is it says undeclared identifier for sliderDidChange can some one please help me with this i can;t find any answers.

h. file

//
//  LightViewController.h
//  Flash Light
//
//  Created by John Whitney on 12-07-27.
//  Copyright (c) 2012 Perfect Programs. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>

@interface LightViewController : UIViewController {
IBOutlet UISlider *slider;
IBOutlet UISlider *theslider;
IBOutlet UISlider *customslider;
UIButton *onButton;
UIButton *offButton;
UIImageView *onView;
UIImageView *offView;
}

@property(nonatomic, strong) IBOutlet UIButton *onButton;
@property(nonatomic, strong) IBOutlet UIButton *offButton;
@property(nonatomic, strong) IBOutlet UIImageView *onView;
@property(nonatomic, strong) IBOutlet UIImageView *offView;
@property(nonatomic, readonly) float torchLevel;

-(void)sliderDidChange:(UISlider *)slider;
-(BOOL)setTorchModeOnWithLevel:(float)torchLevel error:(NSError **)outError;
-(BOOL)supportsAVCaptureSessionPreset:(NSString *)preset;
-(IBAction)torchOn:(id)sender;
-(IBAction)torchOff:(id)sender;
@end

m.file

UISlider *localslider = [[UISlider alloc] initWithFrame:CGRectMake(20.0f, 20.0f, 280.0f, 40.0f)];
localslider.maximumValue = 1.0f;
localslider.minimumValue = 0.0f;
[localslider setContinuous:YES];
[localslider addTarget:self action:@selector(sliderDidChange:)  forControlEvents:UIControlEventValueChanged];
[self.view addSubview:localslider];


-(void)sliderDidChange:(UISlider *)slider
{

AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
[device lockForConfiguration:nil];
[device setTorchModeOnWithLevel:slider.value error:NULL];
[device unlockForConfiguration];
}

can someone please help quick

  • 1
    Seriously? Is this your first day on Objective C. Are you missing a `}` on the previous method? – Warren P Apr 02 '13 at 23:41
  • Stop reposting the same question: http://stackoverflow.com/questions/15771646/, http://stackoverflow.com/questions/15772671/. That's not acceptable behavior on this site. You have lots of comments under the first question asking for clarification, and you haven't really responded to them. That would be a good first step. See [How do I get attention for old unanswered questions?](http://meta.stackexchange.com/q/7046) for more info. – jscs Apr 03 '13 at 19:18

2 Answers2

0

Well the problem may be you added an { anywhere above that line of code

Please make sure all open braces are closed properly

Lithu T.V
  • 19,955
  • 12
  • 56
  • 101
  • select whole code cmd+A and then press cntrl+I if it properly set the code alignment no issues in brackets – Lithu T.V Apr 02 '13 at 18:45
  • today morning same think i posted in an answer :D – Anoop Vaidya Apr 02 '13 at 18:51
  • @AnoopVaidya once this happened that caused me pull my hair .one of my files is showing lot of errors and cannot find any reason .At last i look on my repo to find my changeset and from there found the problem a "." at the beginning of a .m file [at the start of comment section about the file !!! – Lithu T.V Apr 02 '13 at 18:56
  • all that happened is the screen turned yellow – Spencer Whitney Apr 02 '13 at 18:56
0

I assume 1) you have synthesized your properties in the .m file, 2) you have implemented all methods declared in the .h file also there, and 3) the 6 statements in your .m file with which you create your localslider object, i.e. those followed by -(void)sliderDidChange:(UISlider *)slider, are part of the viewDidLoad method.
In this case, you should only get a warning that the argument slider of your -(void)sliderDidChange:(UISlider *)slider method hides your instance variable with the same name in this method.

Reinhard Männer
  • 14,022
  • 5
  • 54
  • 116