- Home /
How to use didUpdateToLocation to Xcode Touch Library project .m to .mm file C syntex
How to use didUpdateToLocation to Xcode Touch Library project so i can write the plugin for GPS using in Unity3d.
first i write a native app in objective c for getting the gps location on my iphone it works fine as native xcode object c projects does. now my next goal is to make a library or cocos touch static library refereces as link listed below:
http://blog.mediarain.com/2013/03/creating-ios-plugins-for-unity/
http://okita.com/Unity/2015/08/making-an-ios-plugin/
The Orignal Code is so easy and implementation is also easy
but for cocos touch static library .mm file there are some differences :
Orignal Implementation :
(void)viewDidLoad {
[super viewDidLoad];
self.locationManager = [[CLLocationManager alloc]init];
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.delegate = self;
}
And my didToUpdateLocation
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
self.lblLong.text = [NSString stringWithFormat:@"%f",manager.location.coordinate.latitude];
self.lblLat.text = [NSString stringWithFormat:@"%f",manager.location.coordinate.longitude];
}
This method is update automatically when recieved new location you have to write it in .m file.
Now i create a Cocos Static Touch Library Prject and make a .mm file which is basically in C not objective c So how to call these method i try to copy and paste it but it does not work
[self.locationManager startUpdatingLocation];
This is for starting location services.
extern "C" { Write a Function that DidUpdateToLocation() something etc ????
} So i call it from unity3d C#
Your answer
Follow this Question
Related Questions
App will not appear on my iPhone! Help! 0 Answers
Swipe controls work on Android but not on iOS? 0 Answers
Have to "Replace" iOS project every build because of Linker Errors 0 Answers
My app file size doubles that of what the console says it should... 1 Answer
Mix native Objective-C code and Unity3d 0 Answers