• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iPhone: validate a NSString for US zipcode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iPhone: validate a NSString for US zipcode


  • Subject: Re: iPhone: validate a NSString for US zipcode
  • From: Greg Guerin <email@hidden>
  • Date: Thu, 7 Jan 2010 10:19:35 -0700

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.


Use an array of bits, not numeric values. Each bit position is numbered (indexed) by zip-code. The bit is 0 if its zip-code is invalid, 1 if valid.

Time to validate any given zip-code is constant: a couple of shifts and ANDs.

Total data size: 100,000 bits, which is 12.5 KB.

  -- GG
_______________________________________________

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


  • Prev by Date: Is it possible to change the color of selected columns in NSTableView?
  • Next by Date: Re: iPhone: validate a NSString for US zipcode
  • Previous by thread: Re: iPhone: validate a NSString for US zipcode
  • Next by thread: Re: iPhone: validate a NSString for US zipcode
  • Index(es):
    • Date
    • Thread