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

댓글 없음:

댓글 쓰기

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

Xcode 26.* 기반으로 iOS교재를 업데이트하고 있습니다. 기술의 발전이 정말 놀랍습니다. ㅎㅎ

 2025년 9월에 발표된 Xcode 26을 사용해서 다양한 교육용 앱을 만들어 보고 있습니다.  1년전만 해도 예제를 작성하는데 정말 시간이 많이 필요했습니다. ㅎㅎ 그런데 이제는 Claude Code, Cursor IDE, Antigravity를 ...