0

i want to add current location to my form which user fills in the application. the code was running smith first but now cannot access the location. instead i get error as

2015-01-21 15:08:18.728 MyHealth[234:17355] current loc: Error Domain=myDomain 
Code=0 "Unable to determine location" UserInfo=0x16134530 
NSLocalizedDescription=Unable to determine location}

I searched for it on StackOverflow but could not find any answer.

Please help. Thanks in advance..!!

ash_win
  • 195
  • 2
  • 10
  • Please paste your code used to try to determinate user's location, also, when you were successfully testing, were you already on iOS 8 or still on iOS 7 ? – Jerome Diaz Jan 21 '15 at 10:40
  • hi, thanks for the help brother. i got the solution. No i was not working on iOS7 first and that was where the mistake was.. :P I searched on the net to access user location on iOS8 and found the solution. Adding my answer here. thanks anyway :) – ash_win Jan 21 '15 at 13:44

1 Answers1

0

Got the answer it was my mistake though. To access user location on iOS8 you need to request in a bit different manner. Here is what i did:

I first added a variable to my info.plist

NSLocationAlwaysUsageDescription

Then i added following code in my viewController where i was getting the current location

[self.locationManager requestAlwaysAuthorization];

where locationManager is of type CLLocationManager

i found the help from https://stackoverflow.com/a/24718342/3963352

Thanks for help though :)

Community
  • 1
  • 1
ash_win
  • 195
  • 2
  • 10