2014년 11월 9일 일요일

아이폰 - iOS 7.0에서 위도와 경도를 출력하는 데모

iOS 7.0에서 위도와 경도를 출력하는 데모 조회 : 112
나의 폴더 > 아이폰 | 2014-02-13 (Thu) 15:30http://blog.dreamwiz.com/papasmf1/14024951
이번에는 위치만 출력해본다.

1. demoCoreLocation01로 생성한다.
2. CoreLocation framework을 추가한다.
3. 아래의 코드를 추가한다.
//
//  ViewController.m
//  demoCoreLocation01
//
//  Created by JONG DUK KIM on 2014. 2. 13..
//  Copyright (c) 2014년 JONG DUK KIM. All rights reserved.
//

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

@interfaceViewController () <CLLocationManagerDelegate>
@property (nonatomic, strong) CLLocationManager *myLocationManager;

@end

@implementation ViewController
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
  //새로운위치를받는다.
  NSLog(@"Latitude = %f", newLocation.coordinate.latitude);
  NSLog(@"Longitude = %f", newLocation.coordinate.longitude);
}

-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
  //에러가발생한경우
}

- (void)viewDidLoad
{
    [superviewDidLoad];
 // Do any additional setup after loading the view, typically from a nib.

  if ([CLLocationManagerlocationServicesEnabled]) {
        self.myLocationManager = [[CLLocationManageralloc] init];
        self.myLocationManager.delegate = self;

        [self.myLocationManagerstartUpdatingLocation];
    } else {
        //위치서비스가활성화되지않은경우
        NSLog(@"위치서비스가활성화되지않음!");
    }
}

- (void)didReceiveMemoryWarning
{
    [superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

댓글 없음:

댓글 쓰기

참고: 블로그의 회원만 댓글을 작성할 수 있습니다.

송길영 작가의 신간 - "경량문명의 탄생" 독서 후기입니다.

  문명이 바뀌고 있다는 것을 누구나 감지하고 있습니다. ㅎㅎ 중량문명이 아닌 경량문명의 시대가 도래하고 있습니다. 수업을 하면서, 또는 친구들과 대화하면서 문명이 바뀌고 있다는 말을 자주했는데 정말 설명하기 좋은 단어가 바로 "경량문명...