How To Get Rid Of Unused Variable Warning?

Joined
Oct 11, 2011
Messages
46
Reaction score
0
Points
6
Your Mac's Specs
13" MacBook Pro 2.4 GHz 8 GB Ram 250 GB HD, iPhone 4/S 64 GB, iPhone 3GS 16 GB, iPad 16 GB Wi-Fi
basically i have this warning, its nothing big, it just bothers me that its there.

heres my code:



Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    GlobalStrings* theDataObject = [self theGlobalClass];
    theDataObject.deviceUDID =  [[UIDevice currentDevice] name];
    
    self.locationManager = [[CLLocationManager alloc] init];
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    locationManager.delegate = self;
    [locationManager startUpdatingLocation];
    

    NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(sendGPS) userInfo:nil repeats:YES];
    

    
    return YES;
}


i used to have "timer release" at the bottom, but it had errors as this method is connected with another method in the app delegate.


so i had to get rid of it from crashing.


is there anything i can just put in here that useless that'll get rid of it?
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
Not sure exactly what your question is, but if it's about not getting warnings for your unused
timer variable you have two obvious options.

first you can disable the warnings for unused variables in the project build settings, under
the Apple LLVM compiler 3.0 - warnings heading, make sure you only switch these off for
the project, and not for the target app, but be warned this is not advised as you will not
get any warnings about unused variables throughout any your project files.

Second you could use the timer variable in an NSLog statement to get rid of the warnings,
even though the log statement has no other debug purposes, like this.

Code:
NSLog(@"time interval = %f", [timer timeInterval]);
[/CODE

Hope this is of some help.

Regards mark
 
OP
L
Joined
Oct 11, 2011
Messages
46
Reaction score
0
Points
6
Your Mac's Specs
13" MacBook Pro 2.4 GHz 8 GB Ram 250 GB HD, iPhone 4/S 64 GB, iPhone 3GS 16 GB, iPad 16 GB Wi-Fi
thanks for your help mark, i think I'm just going to rewrite my timer code to this:


Code:
[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(sendGPS:) userInfo:nil repeats:YES];
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top