用的教程是Big Nerd Ranch 3th .

whereami 的例子,使用CLLocationManager,书中的代码敲进去,但是没有NSLog location 信息,后来搜了下

http://forums.bignerdranch.com/viewtopic.php?f=216&t=4514a  as responsed by  Basilornis

The solution is twofold. If you are using Xcode5 you are using a storyboard. This does not call initWithNib. In order to get code execution going in whereAmI, you must replace that section with the following:

原来Xcode5 用的是storyboard not Nib, 所以没有反应,注意拼写啊,分清楚 location ///locaitons , 最后问题解决。

 1 #import "WhereamiViewController.h"
 2 
 3 @implementation WhereamiViewController
 4 
 5 - (id)initWithCoder:(NSCoder *)aDecoder
 6 {
 7     self = [super initWithCoder:(NSCoder *)aDecoder];
 8     
 9     if (self) {
10         // Create location manager object
11         locationManager = [[CLLocationManager alloc] init];
12         
13         [locationManager setDelegate:self];
14         
15         // And we want it to be as accurate as possible
16         [locationManager setDesiredAccuracy: kCLLocationAccuracyBest];
17         
18         // Test our manager to start looking for its location
19         [locationManager startUpdatingLocation];
20         
21     }
22     return self;
23 }
24 - (void) locationManager: (CLLocationManager *)manager
25       didUpdateLocations:(NSArray *) locations
26 
27 {
28     NSLog(@"%@", [locations lastObject]);
29 }
30 
31 - (void)locationManager: (CLLocationManager *)manager
32 didFailWithError:(NSError *)error
33 {
34     NSLog(@"Could not find location: %@", error);
35 }
36 @end
View Code

 

posted on 2014-05-16 11:45  sokeyer  阅读(184)  评论(0编辑  收藏  举报