2010-12-04 3 views
0

in meiner Header-Datei deklariert ich immer bin, wenn ich diese Zeile hinzu:Objective C: seltsame Fehler, wenn init eine Variable

locMan = [[CLLocationManager alloc] init]; 

Zum viewDidLoad Methode in meiner .m-Datei erhalte ich einige Fehler, die ich habe noch nie vorher gesehen. Hier sind die Fehler:

alt text

Ich kann nicht für das Leben von mir herauszufinden, warum fügte hinzu, dass Leitungsprobleme verursacht. Wenn jemand etwas Licht geben kann, wäre ich sehr dankbar.

Ich habe diese Header-Datei:

#import <UIKit/UIKit.h> 
#import "CoreLocation/CoreLocation.h" 


@interface RobotWarsViewController : UIViewController 
<CLLocationManagerDelegate> { 

    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 

Und diese .m-Datei:

#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 

Antwort

3

Haben Sie das CoreLocation-Framework zu Ihrem Projekt hinzugefügt?

Erweitern Sie die Frameworks-Gruppe, und sehen Sie, ob CoreLocation dort aufgeführt ist. Wenn nicht, rechtsklicke darauf und füge hinzu.

+0

Danke danke danke! – sixtyfootersdude

2

Sie nicht den Rahmen Corelocation zu einem Projekt hinzugefügt haben.

Verwandte Themen