Apple Watchプログラミングの作法 Extensionアプリ/Objective-C対応

位置情報を利用する(CoreLocation/MapKit) - コーディング

Icon comment count 0
Icon stock count 0

10.5 コーディング

それではコーディングに入ります。本アプリはすべてExtension側に実装していますので、iOSアプリのAppDelegate、ViewControllerにはプログラムコードが何もありません。

10.5.1 初期化部分

次は初期化部分のコードです。

InterfaceController.m
@interface InterfaceController() {
  
  CLLocationManager *locationManager;        // ロケーションマネージャ
  CLLocationCoordinate2D userLocation;       // 現在位置
  BOOL deferredLocationUpdates;              // Deferrdアップデートフラグ
  CLLocationCoordinate2D mapCenterLocation;  // 地図の中心位置
  MKCoordinateSpan span;                     // 地図の表示範囲
  float  spanValue;                              //
  NSTimer *intervalTimer;                    // 地図の更新タイマー
}
// 地図オブジェクト
@property (weak, nonatomic) IBOutlet WKInterfaceMap *mapView;
@end
@implementation InterfaceController
- (void)awakeWithContext:(id)context {
  [super awakeWithContext:context];
  
  // ユーザーに位置情報利用の承諾を得る
  l

コメント

    コメントはありません