Skip to content
Browse files

Added OS X support for Address formatter (/thanks @tullera)

  • Loading branch information...
1 parent 9c670ad commit f45eeddfcb7a8ce7a3666f5067aa79a3f4ddf644 @mattt committed Nov 24, 2012
Showing with 8 additions and 2 deletions.
  1. +1 −1 FormatterKit/TTTAddressFormatter.h
  2. +7 −1 FormatterKit/TTTAddressFormatter.m
View
2 FormatterKit/TTTAddressFormatter.h
@@ -23,7 +23,7 @@
#import <Foundation/Foundation.h>
#import <Availability.h>
-#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && defined(__ABPerson__)
+#if defined(__ABPerson__)
/**
Instances of `TTTAddressFormatter` create address strings formatted according to a given locale.
View
8 FormatterKit/TTTAddressFormatter.m
@@ -22,7 +22,7 @@
#import "TTTAddressFormatter.h"
-#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && defined(__ABPerson__)
+#if defined(__ABPerson__)
@implementation TTTAddressFormatter
@synthesize locale = _locale;
@@ -68,7 +68,13 @@ - (NSString *)stringFromAddressWithStreet:(NSString *)street
[mutableAddressComponents setValue:[self.locale objectForKey:NSLocaleCountryCode] forKey:(__bridge NSString *)kABPersonAddressCountryCodeKey];
+#if __IPHONE_OS_VERSION_MIN_REQUIRED
return ABCreateStringWithAddressDictionary(mutableAddressComponents, !!country);
+#elif __MAC_OS_X_VERSION_MIN_REQUIRED
+ return [[[ABAddressBook sharedAddressBook] formattedAddressFromDictionary:mutableAddressComponents] string];
+#else
+ return nil;
+#endif
}
#pragma mark NSFormatter

0 comments on commit f45eedd

Please sign in to comment.
Something went wrong with that request. Please try again.