• 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: Paul Bruneau <email@hidden>
  • Date: Thu, 7 Jan 2010 11:45:10 -0500

I'm a little unclear what you are asking, but I'll tell what I know. You just want to know if a 5 digit zip code is a valid one? Or do you want to compare it to the list of valid city names that are assigned to it? (yes it can be more than one, ugh)

They are (from a non-USPS point of view) arbitrarily assigned by the post office and there are currently 42,305 or so assigned (out of a theoretical maximum of 100,000 of course)

So assuming you just want to know if it's a valid zip (and don't care about if they got the city right), the only way to validate it solely from within your app as a valid zip code would be to have a list of them in your app.

You could load them from a plist or straight text I guess into an NSArray or NSSet and then check to see if the zip is valid as needed.

You can get the list from a third party service like http://www.zipcodeworld.com/ or maybe from some free source.

The value of this might be questionable, since a zip code with a typo still has roughly a 50% chance of being a valid one. Plus the USPS is always adding new ones, so will you risk telling your user that his zip code doesn't exist when he is standing in it?

So I guess the answer is there is no Cocoa technology that can help with this--unless you are asking something completely different, in which case let's all have a good chuckle at my poor comprehension skills :)

On Jan 7, 2010, at 11:11 AM, Eric E. Dolecki wrote:

I've been googling but haven't seen yet how to best validate a 5-digit
zipcode for use in the US (without using a webservice).

I have the NSString, I just need to validate it. I know zero RegExp, is
there a formatter I can use?
_______________________________________________

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


  • Follow-Ups:
    • Re: iPhone: validate a NSString for US zipcode
      • From: "Eric E. Dolecki" <email@hidden>
References: 
 >iPhone: validate a NSString for US zipcode (From: "Eric E. Dolecki" <email@hidden>)

  • Prev by Date: Julian date
  • Next by Date: Re: iPhone: validate a NSString for US zipcode
  • Previous by thread: iPhone: validate a NSString for US zipcode
  • Next by thread: Re: iPhone: validate a NSString for US zipcode
  • Index(es):
    • Date
    • Thread