Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198
CPPhoneNumber: Difference between revisions - iPhone Development Wiki

CPPhoneNumber: Difference between revisions

From iPhone Development Wiki
m (Reference)
(Added informations on CPPhoneNumbersEqual)
Line 1: Line 1:
[[CPPhoneNumber]] is a set of utility functions in {{fwlink|AppSupport}} for handling phone numbers
[[CPPhoneNumber]] is a set of utility functions in {{fwlink|AppSupport}} for handling phone numbers.


== Normalizing ==
== Normalizing ==
Line 14: Line 14:
free(pn);
free(pn);
...
...
</source>
== Comparing ==
{{Function signature|signature=BOOL CPPhoneNumbersEqual(const char* number1,const char* number2, CFStringRef country);|firmware=? –}}
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:
<source lang="cpp">
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
</source>
</source>



Revision as of 03:39, 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 char *CPPhoneNumberCopyNormalized(char *);

...
	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

References

External links