iOS-위치 처리
사용자가 핵심 위치 프레임 워크의 도움으로 정보에 액세스 할 수 있도록 허용하는 경우 iOS에서 사용자의 현재 위치를 쉽게 찾을 수 있습니다.
위치 처리 – 관련 단계
Step 1 − 간단한보기 기반 응용 프로그램을 만듭니다.
Step 2 − 프로젝트 파일을 선택한 다음 타겟을 선택하고 아래와 같이 CoreLocation.framework를 추가합니다 −
                Step 3 − 두 개의 라벨 추가 ViewController.xib 레이블 이름을 지정하는 ibOutlets를 다음과 같이 만듭니다. latitudeLabel 과 longitudeLabel 각기.
Step 4 − 파일 → 새로 만들기 → 파일 ...을 선택하여 새 파일을 생성하고 → Objective C class 다음을 클릭하십시오.
Step 5 − 클래스 이름을 LocationHandler 와 "sub class of" NSObject로.
Step 6 − 생성을 선택합니다.
Step 7 − 업데이트 LocationHandler.h 다음과 같이-
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@protocol LocationHandlerDelegate <NSObject>
@required
-(void) didUpdateToLocation:(CLLocation*)newLocation 
   fromLocation:(CLLocation*)oldLocation;
@end
@interface LocationHandler : NSObject<CLLocationManagerDelegate> {
   CLLocationManager *locationManager;
}
@property(nonatomic,strong) id<LocationHandlerDelegate> delegate;
+(id)getSharedInstance;
-(void)startUpdating;
-(void) stopUpdating;
@end 
    Step 8 − 업데이트 LocationHandler.m 다음과 같이-
#import "LocationHandler.h"
static LocationHandler *DefaultManager = nil;
@interface LocationHandler()
-(void)initiate;
@end
@implementation LocationHandler
+(id)getSharedInstance{
   if (!DefaultManager) {
      DefaultManager = [[self allocWithZone:NULL]init];
      [DefaultManager initiate];
   }
   return DefaultManager;
}
-(void)initiate {
   locationManager = [[CLLocationManager alloc]init];
   locationManager.delegate = self;
}
-(void)startUpdating{
   [locationManager startUpdatingLocation];
}
-(void) stopUpdating {
   [locationManager stopUpdatingLocation];
}
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:
   (CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
   if ([self.delegate respondsToSelector:@selector
   (didUpdateToLocation:fromLocation:)]) {
      [self.delegate didUpdateToLocation:oldLocation 
      fromLocation:newLocation];
   }
}
@end 
    Step 9 − 업데이트 ViewController.h 우리가 구현 한 다음과 같이 LocationHandler delegate 두 개의 ibOutlets를 만듭니다.
#import <UIKit/UIKit.h>
#import "LocationHandler.h"
@interface ViewController : UIViewController<LocationHandlerDelegate> {
   IBOutlet UILabel *latitudeLabel;
   IBOutlet UILabel *longitudeLabel;
}
@end 
    Step 10 − 업데이트 ViewController.m 다음과 같이-
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
   [super viewDidLoad];
   [[LocationHandler getSharedInstance]setDelegate:self];
   [[LocationHandler getSharedInstance]startUpdating];
}
- (void)didReceiveMemoryWarning {
   [super didReceiveMemoryWarning];
   // Dispose of any resources that can be recreated.
}
-(void)didUpdateToLocation:(CLLocation *)newLocation 
 fromLocation:(CLLocation *)oldLocation {
   [latitudeLabel setText:[NSString stringWithFormat:
   @"Latitude: %f",newLocation.coordinate.latitude]];
   [longitudeLabel setText:[NSString stringWithFormat:
   @"Longitude: %f",newLocation.coordinate.longitude]];
}
@end 
    산출
응용 프로그램을 실행하면 다음과 같은 출력이 표시됩니다.