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

댓글 없음:

댓글 쓰기

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

인재들의 ‘탈 공대’로 무너져가는 이공계 🤖한국 과학기술의 현주소ㅣ KBS 다큐 인사이트 - 인재전쟁 2부 의대에 미친 한국

  대부분의 내용들은 우리가 이미 알고 있는 내용들입니다. ㅎㅎ 공대가 인기가 있었던 것은 80년대와 90년대 였던 것 같습니다. IMF위기를 겪고 나서 지금처럼 의대로 방향이 바뀌었네요. 한국은 AI분야에서 보면 참으로 척박한 땅입니다. 거의 기술의...