Note that there are some explanatory texts on larger screens.

plurals
  1. POObjective C: strange error when init a variable declared in my header file
    text
    copied!<p>I am getting when I add this line: </p> <pre><code>locMan = [[CLLocationManager alloc] init]; </code></pre> <p>To the <code>viewDidLoad</code> method inside of my .m file I get some errors that I have never seen before. Here are the errors: </p> <p><img src="https://i.stack.imgur.com/Fxwyo.png" alt="alt text"></p> <p>I cannot for the life of me figure out why adding that line is causing problems. If anyone can shed some light I would be very grateful. </p> <p>I have this header file: </p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "CoreLocation/CoreLocation.h" @interface RobotWarsViewController : UIViewController &lt;CLLocationManagerDelegate&gt; { CLLocationManager *locMan; // Current Location View IBOutlet UIView *currentLocationView; IBOutlet UILabel *currentLocationLabel; } @property (assign, nonatomic) UIView *currentLocationView; @property (assign, nonatomic) UILabel *currentLocationLabel; @property (assign, nonatomic) CLLocationManager *locMan; - (IBAction)dropEMP:(id)sender; - (IBAction)armEMP:(id)sender; @end </code></pre> <p>And this .m file: </p> <pre><code>#import "RobotWarsViewController.h" @implementation RobotWarsViewController @synthesize locMan; @synthesize currentLocationView; @synthesize currentLocationLabel; - (void)viewDidLoad { [super viewDidLoad]; locMan = [[CLLocationManager alloc] init]; // locMan.delegate = self; } - (IBAction)dropEMP:(id)sender{ NSLog(@"Boo"); } - (IBAction)armEMP:(id)sender{ NSLog(@"boo"); } - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSLog(@"location update"); } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [super dealloc]; [currentLocationView release]; [currentLocationLabel release]; } @end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload