(Added informations on CPPhoneNumbersEqual) |
(Added informations on CPPhoneNumbersEqual) |
||
(One intermediate revision by the same user not shown) | |||
Line 6: | Line 6: | ||
CPPhoneNumberCopyNormalized returns a normalized copy<ref name="tn">https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html</ref> of a phone number. | CPPhoneNumberCopyNormalized returns a normalized copy<ref name="tn">https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html</ref> of a phone number. | ||
<source lang=" | <source lang="cpp"> | ||
extern char *CPPhoneNumberCopyNormalized(char *); | extern "C" char *CPPhoneNumberCopyNormalized(const char* number); | ||
char *pn = CPPhoneNumberCopyNormalized("+1 (555) 555-5555"); | |||
printf("%s\n", pn); // 15555555555 | |||
free(pn); | |||
</source> | </source> | ||
Line 27: | Line 26: | ||
extern "C" BOOL CPPhoneNumbersEqual(const char* number1, const char* number2, CFStringRef country); | extern "C" BOOL CPPhoneNumbersEqual(const char* number1, const char* number2, CFStringRef country); | ||
BOOL equal = CPPhoneNumbersEqual("+49302270", "0302270", CPPhoneNumberCopyHomeCountryCode()); //should return YES | BOOL equal = CPPhoneNumbersEqual("+49302270", "0302270", CPPhoneNumberCopyHomeCountryCode()); //should return YES, if you're phone is in Germany/using a german SIM Card | ||
</source> | </source> | ||
Latest revision as of 03:43, 5 January 2015
CPPhoneNumber is a set of utility functions in AppSupport for handling phone numbers.
Normalizing
Signature | char *CPPhoneNumberCopyNormalized(char *); |
---|---|
Available in | ? – |
CPPhoneNumberCopyNormalized returns a normalized copy[1] of a phone number.
extern "C" char *CPPhoneNumberCopyNormalized(const char* number);
char *pn = CPPhoneNumberCopyNormalized("+1 (555) 555-5555");
printf("%s\n", pn); // 15555555555
free(pn);
Comparing
Signature | BOOL CPPhoneNumbersEqual(const char* number1,const char* number2, CFStringRef country); |
---|---|
Available in | ? – |
CPPhoneNumbersEqual compares two phone numbers. It will automatically normalize the number, and add an country code if the number does not contain one. It is extremely useful, if you have to compare an incoming call against an user supplied phone number.
You could compare two German phone numbers like this:
extern "C" CFStringRef CPPhoneNumberCopyHomeCountryCode();
extern "C" BOOL CPPhoneNumbersEqual(const char* number1, const char* number2, CFStringRef country);
BOOL equal = CPPhoneNumbersEqual("+49302270", "0302270", CPPhoneNumberCopyHomeCountryCode()); //should return YES, if you're phone is in Germany/using a german SIM Card
References
External links
|