iPhone - 验证美国城市和州
在我的应用程序中,我有两个文本字段,用户可以在其中输入城市和州。 我想验证输入的城市是否在输入的州内。 该应用程序仅针对美国人。那么有什么方法可以验证城市和州的详细信息吗?
In my app, i've two text fields where user can enter city and state.
I want to validate whether city entered is within the state entered.
The app is targeted for USA people only. So is there any way to validate the city and state details?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 Google Maps API (http://code.google.com/apis/maps/documentation/webservices/index.html) 并检查位置。
因此,您无需维护详尽的列表,并且始终保持最新状态。
Have a look at the Google Maps API (http://code.google.com/apis/maps/documentation/webservices/index.html) and Check for Location.
So you don't have to maintain an extensive list and are always up to date.
我可以考虑使用带有城市的
nsarray
和以州为键的nsdictionary
。用户输入州和城市后,您可以使用州作为键获取对象数组,并将输入的城市与返回数组中的对象进行比较。I can think of using a
nsdictionary
withnsarray
of cities and with state as the key. Once the user enters the state and city, you can get the array of objects using the state as the key and compare the entered city with the objects in the returned array.