Comments (2)
Okay, I just wrote one.
APAddress.h:
- (NSString *) toString;
APAddress.m:
- (NSString *) toString
{
BOOL hasStreet = (self.street && [self.street length]);
BOOL hasCity = (self.city && [self.city length]);
BOOL hasState = (self.state && [self.state length]);
BOOL hasZip = (self.zip && [self.zip length]);
BOOL hasCountry = (self.country && [self.country length]);
BOOL hasCountryCode = (self.countryCode && [self.countryCode length]);
BOOL countryCodeIsNumeric = ([[NSNumberFormatter new] numberFromString:self.countryCode] != nil);
NSMutableString *str = [NSMutableString new];
// Street
if (hasStreet)
{
[str appendString:[self.street capitalizedString]];
[str appendString:@", "];
}
// City
if (hasCity)
{
[str appendString:[self.city capitalizedString]];
[str appendString:@", "];
}
// State
if (hasState)
{
if ([self.state length]) > 2)
[str appendString:[self.state capitalizedString]];
else
[str appendString:[self.state uppercaseString]];
if (hasZip) [str appendString:@" "];
else [str appendString:@", "];
}
// Zip
if (hasZip)
{
[str appendString:self.zip];
[str appendString:@", "];
}
// Country
if (hasCountryCode && !countryCodeIsNumeric)
[str appendString:[self.countryCode uppercaseString]];
else if (hasCountry)
[str appendString:[self.country capitalizedString]];
// Clean up the string
[str setString:[str stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@", \t\n"]]];
return [NSString stringWithString:str];
}
from apaddressbook.
Looks good but in different countries different address formats. So, it's not suitable for all.
You can create category on APContact
and use it your projects
from apaddressbook.
Related Issues (20)
- Urgent : Message from debugger: Terminated due to memory issue HOT 5
- How to install latest 0.3.1 Version using Pod? HOT 2
- how to display contacts sorted alphabetically HOT 1
- Unable to get the address information HOT 5
- Get Contact Identifier HOT 2
- Can the contacts be persisted in some data store HOT 1
- No visible @interface for 'ContactTableViewCell' declares the selector 'updateWithContact:' HOT 1
- StartObserverChangeswithCallback gets fired multiple time even for a single change in address book HOT 3
- Contact phone number array object prefix with (null) ((null)) - in Xcode 8.2.1 HOT 3
- APAddressBook excessive memory consumption with a large number of contacts HOT 1
- Select the address book HOT 1
- Single contact going duplicate multiple time HOT 2
- Swift 4 update HOT 1
- Is RecordID always unique? HOT 2
- How can I get google id (social type id) HOT 5
- Adding New Contacts Don't Appear In List HOT 2
- 'ABRecordRef' is deprecated: first deprecated in iOS 9.0 HOT 1
- Address not showing. HOT 3
- Add nonGregorianBirthday field to APContact
- APAddressBookExternalChangeRoutine crash HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apaddressbook.