Re: iPhone: validate a NSString for US zipcode
Re: iPhone: validate a NSString for US zipcode
- Subject: Re: iPhone: validate a NSString for US zipcode
- From: David Duncan <email@hidden>
- Date: Thu, 7 Jan 2010 09:29:35 -0800
On Jan 7, 2010, at 8:53 AM, Eric E. Dolecki wrote:
> I don't care about the city, just that the zip code will work. On an iPhone
> testing against an array of 42,305 values... could that be pretty quick?
> Seems like a large set to go through looking. I'm sending the value to a
> webservice to return weather data.
Given that you would likely want to do this test with a binary search I don't see any reason why it should be slow (effectively you can do the entire search with about 17*k compares). The bigger concern with validation would be in having the complete list of zip codes to validate against.
It might make more sense to see if your weather service can "fast fail" on an invalid zip code, since they will likely maintain a valid zip code list, and if you do it yourself you would want to maintain the same one they do.
--
David Duncan
Apple DTS Animation and Printing
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden