Get User's Country

落爺英雄遲暮 提交于 2020-01-02 06:54:07

问题


I just wanted to know how I could find out the current user's country using Xcode (iPhone Dev SDK).


回答1:


If you want to get the users country you can do two things. The easiest is to deciper it from their localization settings.

NSLocale *locale = [NSLocale currentLocale];
NSString *country = [locale displayNameForKey:NSLocaleIdentifier value:[locale localeIdentifier]];

This can be unreliable (e.g. a user who is abroad). If you depend on the information you should use CoreLocation to find the users current location and then use reverse geo-tagging to get the country from the co-ordinates. Take a look at the CoreLocation Framework reference. It should help you.



来源:https://stackoverflow.com/questions/5095814/get-users-country

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!