【问题标题】:CLLocationManager startUpdatingLocation not found找不到 CLLocationManager startUpdatingLocation
【发布时间】:2012-12-12 22:11:15
【问题描述】:

我一直在尝试向我的应用程序添加一项功能以获取位置并将变量放入 mysql 数据库。我添加了 CoreLocation.framework 并在标题中导入了<CoreLocation/CoreLocation.h>。我尝试了不同的代码,但我总是会遇到类似的错误,例如下面评论的错误。框架是否可能没有正确链接?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:   (NSDictionary *)launchOptions                              
{ 
 CLLocationManager = self; // Expected identifier or '('
 [self startUpdatingLocation:nil]; // instance method '-startUpdatingLocation' not found
}



-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
 CLLocationManager *locationManager = [[CLLocationManager alloc] release];
//initializing 'CLLocationManager *' with an expression of incompatible type 'void'
[locationManager startUpdatingLocation:nil];
//do stuff with the coordinates
}



@end

【问题讨论】:

    标签: ios4 core-location cllocationmanager


    【解决方案1】:

    请找到您的代码的更正。它应该工作。之后,您的代码应该实现 CLLocationManagerDelegate 方法来获取位置信息。

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:   (NSDictionary *)launchOptions                              
    { 
    CLLocationManager *locationManager = [[CLLocationManager alloc] init];
     locationManager.delegate = self;
    [locationManager startUpdatingLocation:nil];}
    
    
    
    -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
    
     CLLocationManager *locationManager = [[CLLocationManager alloc] init];
     locationManager.delegate = self;
    [locationManager startUpdatingLocation:nil];
    
    //do stuff with the coordinates
    }
    

    【讨论】:

      猜你喜欢
      • 2012-07-26
      • 1970-01-01
      • 1970-01-01
      • 2014-11-13
      • 2016-05-30
      • 2016-02-17
      • 2016-05-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多