Modifying Email Addresses in Objective-C

Create Data Matrix ECC200 in Objective-C Modifying Email Addresses

Modifying Email Addresses
DataMatrix Encoder In Objective-C
Using Barcode creation for iPhone Control to generate, create Data Matrix image in iPhone applications.
www.OnBarcode.com
Encoding UCC.EAN - 128 In Objective-C
Using Barcode drawer for iPhone Control to generate, create UCC.EAN - 128 image in iPhone applications.
www.OnBarcode.com
The basic fields shown in the previous section all support a single entry. An email address is a String, but any given user may have multiple addresses. BlackBerry devices support up to three addresses for any given contact. You may simply call addField() multiple times, as in the following example.
Barcode Maker In Objective-C
Using Barcode creation for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
Barcode Generation In Objective-C
Using Barcode encoder for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
contact.addString(Contact.EMAIL, PIMItem.ATTR_NONE, "westley@example.com"); contact.addString(Contact.EMAIL, PIMItem.ATTR_NONE, "farmboy@example.com"); contact.addString(Contact.EMAIL, PIMItem.ATTR_NONE, "dread.pirate@example.com");
Code128 Printer In Objective-C
Using Barcode encoder for iPhone Control to generate, create Code 128B image in iPhone applications.
www.OnBarcode.com
Generate European Article Number 13 In Objective-C
Using Barcode creator for iPhone Control to generate, create EAN-13 Supplement 5 image in iPhone applications.
www.OnBarcode.com
Should you ever need to add another address once the maximum has been reached, you must remove one of the existing ones first. You can remove any field, not just email
Creating Code 39 Extended In Objective-C
Using Barcode generator for iPhone Control to generate, create ANSI/AIM Code 39 image in iPhone applications.
www.OnBarcode.com
GS1 - 12 Drawer In Objective-C
Using Barcode encoder for iPhone Control to generate, create Universal Product Code version E image in iPhone applications.
www.OnBarcode.com
Download at
Data Matrix 2d Barcode Scanner In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Encoding Data Matrix ECC200 In Objective-C
Using Barcode generation for iPhone Control to generate, create ECC200 image in iPhone applications.
www.OnBarcode.com
CHAPTER 6: Personal Information
PDF 417 Maker In None
Using Barcode maker for Online Control to generate, create PDF-417 2d barcode image in Online applications.
www.OnBarcode.com
Painting GTIN - 12 In None
Using Barcode encoder for Font Control to generate, create GTIN - 12 image in Font applications.
www.OnBarcode.com
addresses, by calling the removeValue() method. The example below will remove the second item; if run after the preceding code, the two remaining addresses will be westley@example.com at index 0 and dread.pirate@example.com at index 1. contact.removeValue(Contact.EMAIL, 1); New email addresses will always be added to the end of the list. You can call setString() with the appropriate index to modify an existing email address slot.
Draw Code 128C In None
Using Barcode generation for Font Control to generate, create Code 128A image in Font applications.
www.OnBarcode.com
Create UPCA In Visual C#.NET
Using Barcode drawer for VS .NET Control to generate, create UPC A image in Visual Studio .NET applications.
www.OnBarcode.com
Modifying Names
GTIN - 13 Scanner In None
Using Barcode reader for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
QR Code ISO/IEC18004 Generation In Objective-C
Using Barcode printer for iPad Control to generate, create Denso QR Bar Code image in iPad applications.
www.OnBarcode.com
Contact.NAME has the type PIMItem.STRING_ARRAY. It is helpful to be able to access individual components of a name; for example, John Smith can be easily sorted by first name, but you d like individual access to the Smith part in order to sort by the last name. PIM defines five potential elements that make up the name array. BlackBerry supports a subset of these, as shown in Table 6-2.
Generating Barcode In None
Using Barcode creator for Word Control to generate, create Barcode image in Word applications.
www.OnBarcode.com
GS1 - 13 Creator In VS .NET
Using Barcode maker for ASP.NET Control to generate, create EAN13 image in ASP.NET applications.
www.OnBarcode.com
Table 6-2. Elements in the Name Array
Printing Code 39 Full ASCII In None
Using Barcode maker for Office Excel Control to generate, create Code 39 image in Office Excel applications.
www.OnBarcode.com
Create ANSI/AIM Code 128 In None
Using Barcode generation for Online Control to generate, create Code 128 Code Set A image in Online applications.
www.OnBarcode.com
Name
Contact.NAME_FAMILY Contact.NAME_GIVEN Contact.NAME_OTHER Contact.NAME_PREFIX Contact.NAME_SUFFIX
Meaning
Last name First name Middle name, nick name, etc. Honorific or title placed before name Honors, offices, or generational information
Example
House Gregory Greg Dr. M.D.
Supported
Yes Yes No Yes No
You cannot directly set an individual name element; instead, you must add or remove the entire string array at once. You can build up and apply the array as shown in the following example.
int nameCount = contacts.stringArraySize(Contact.NAME); String[] names = new String[nameCount]; names[Contact.NAME_PREFIX] = "Dr."; names[Contact.NAME_GIVEN] = "Nick"; names[Contact.NAME_FAMILY] = "Riviera"; names[Contact.NAME_SUFFIX] = "M.D."; contact.addStringArray(Contact.NAME, PIMItem.ATTR_NONE, names);
You can include as few name parts as you like, although, if neither a given nor a family name is included, BlackBerry will apply a default of Empty and Contact respectively. It is safe to include unsupported name parts such as NAME_SUFFIX. These will be silently discarded. If you d prefer to check at runtime whether a name is supported, use the method isSupportedArrayElement().
Download at
CHAPTER 6: Personal Information
if (contacts.isSupportedArrayElement(Contact.NAME, Contact.NAME_SUFFIX)) names[Contact.NAME_SUFFIX] = "M.D.";
Modifying Phone Numbers
The phone number field is the first that supports attributes. As described previously, an attribute provides more detailed information about the data it contains. When you add multiple email addresses, there is no way to distinguish whether one email address will be more appropriate than another to use. For phone numbers, however, you can attach an attribute to each number describing its purpose, as the following code demonstrates.
contact.addString(Contact.TEL, Contact.ATTR_HOME, "5555550100"); contact.addString(Contact.TEL, Contact.ATTR_WORK, "5555550103"); contact.addString(Contact.TEL, BlackBerryContact.ATTR_WORK2, "5555550104");
As long as you stick to the defined attributes and don t repeat yourself, everything will work as expected. However, BlackBerry follows some unusual rules in other cases. If you try to add an attribute that isn t supported (such as Contact.AUTO), or one that already has a value assigned to it, then, rather than discarding the value or throwing an error, the number will be assigned to the next available slot. Therefore, it is possible for your code to add a mobile number to a contact, and have that number stored as a pager number. There is a limit of eight numbers per contact, and adding any more after that will result in a FieldFullException. To avoid this problem, you can use the countValues() method to determine how many entries are already stored in a field, and then a getAttributes() call to retrieve the attributes. Attributes are bit flags, so you can use a bitwise AND operator to determine whether a given attribute is set, as shown in the next example. This code will scan through all the telephone numbers already set on a contact and, if it finds a mobile number, update it.
int telCount = contact.countValues(Contact.TEL); for (int i = 0; i < telCount; ++i) { int telAttrs = contact.getAttributes(Contact.TEL, i); if ((telAttrs & Contact.ATTR_MOBILE) != 0) { contact.setString(Contact.TEL, i, Contact.ATTR_MOBILE, "5555550109"); break; } }
Copyright © OnBarcode.com . All rights reserved.