Inside the app delegate of an iphone application, I have declared a protocol as given below:
There is an instance of CLLocationManager inside the app delegate with property as given below:
After synthesizing all the required fields, I have used the below given code:
In another view controller, I hae implemented the UILocationDelegate as given below:
In the .m file of this viewcontroller, I have written:
Is there anything wrong with the above given logic as I want to handle the callbacks from the CLLocationManager but the event in the above viewcontroller is not getting raised.
Thanks
Arnieterm
Code:
@protocol UILocationDelegate <NSObject>
@required
-(void) locationChanged:(float)newlatitude:(float)newlongitude;
@end
Code:
CLLocationManager* locationManager;
id delegate;
@property(nonatomic,retain)CLLocationManager* locationManager;
@property (nonatomic,assign) id <UILocationDelegate> delegate;
After synthesizing all the required fields, I have used the below given code:
Code:
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
[self.delegate locationChanged:newLocation.coordinate.latitude:newLocation.coordinate.longitude];
}
In another view controller, I hae implemented the UILocationDelegate as given below:
Code:
@interface UIMyController : UIViewController <UIAlertViewDelegate,UILocationDelegate,UIScrollViewDelegate>
In the .m file of this viewcontroller, I have written:
Code:
-(void) locationChanged:(float)newlatitude:(float)newlongitude
{
}
Thanks
Arnieterm