Accessing the Address Book in Objective-C

Making QR-Code in Objective-C Accessing the Address Book

Accessing the Address Book
QR Printer In Objective-C
Using Barcode maker for iPhone Control to generate, create QR Code ISO/IEC18004 image in iPhone applications.
www.OnBarcode.com
Barcode Generator In Objective-C
Using Barcode maker for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
Using Core Foundation
Generating ECC200 In Objective-C
Using Barcode encoder for iPhone Control to generate, create ECC200 image in iPhone applications.
www.OnBarcode.com
Encoding Denso QR Bar Code In Objective-C
Using Barcode maker for iPhone Control to generate, create Quick Response Code image in iPhone applications.
www.OnBarcode.com
The Address Book framework is the first framework you ve worked with that requires you to use Core Foundation, a non-Cocoa library. This means you ll have to program slightly differently, as we promised would be the case back in chapter 10. The biggest differences are how variables and memory allocation work. Core Foundation variables use different classes, such as CFStringRef replacing NSString *. Remember that the Core Foundation variable types usually have equivalents in Cocoa that you can freely switch between by casting, as is done in listing 16.10 when moving between the Address Book records and the UITextView text. When you re using the Core Foundation variables natively, you ll have to use Core Foundation functions, such as CFArrayCount, to deal with them. You ll also have to deal with memory management a little differently. Core Foundation memory management uses the same general approach as Cocoa Touch. There s a reference count for each object that is increased when it s created or retained and decreased when it s released. You just have to remember slightly different rules for when you have a reference. If you create an object with a function using the word(s) create or copy, you own a reference to it and must CFRelease it. If you create an object in another way, you do not have a reference, and you must CFRetain the object if you want to keep it around. Some classes of objects may have their own release and retain functions. The Memory Management Programming Guide for Core Foundation tutorial at developer.apple.com has more information. Core Foundation will show up again in chapter 18, where it controls some audio services, and in chapter 19, where it s used for the Quartz 2D graphics package.
UPC-A Supplement 2 Printer In Objective-C
Using Barcode encoder for iPhone Control to generate, create UCC - 12 image in iPhone applications.
www.OnBarcode.com
Code 3/9 Drawer In Objective-C
Using Barcode maker for iPhone Control to generate, create ANSI/AIM Code 39 image in iPhone applications.
www.OnBarcode.com
There are three other view controllers that you can use to allow users to interact with the Address Book.
Code-128 Maker In Objective-C
Using Barcode creation for iPhone Control to generate, create USS Code 128 image in iPhone applications.
www.OnBarcode.com
UPC-E Drawer In Objective-C
Using Barcode generation for iPhone Control to generate, create Universal Product Code version E image in iPhone applications.
www.OnBarcode.com
THE OTHER VIEW CONTROLLERS
Printing Quick Response Code In Java
Using Barcode drawer for BIRT reports Control to generate, create QR-Code image in BIRT reports applications.
www.OnBarcode.com
QR Code ISO/IEC18004 Creator In None
Using Barcode generation for Software Control to generate, create Quick Response Code image in Software applications.
www.OnBarcode.com
The other three view controllers work much like ABPeoplePickerNavigationController, with one notable difference: they must each be built on top of a navigation controller. Technically, they re probably not modal view controllers, because they go inside a navigation controller, but you can treat the navigation controller as a modal view controller once everything is loaded up, as you ll see in our example. The ABNewPersonViewController allows a user to enter a new contact. You can prefill some of the info by recording it in an ABRecordRef and setting the displayedPerson property, but this is purely optional (and probably won t usually be done). Once you ve created the controller, you ll need to respond to a method that tells you when the user has entered a new contact. You don t have to do anything with it except dismiss the modal controller, because the controller automatically saves the new contact to the Address Book. You can see what info the user entered, though, and do something with it if you want. Listing 16.12 shows how to deploy a new-person view on top of a navigation controller, and how to respond to its single method.
Decoding EAN 13 In C#.NET
Using Barcode reader for .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Quick Response Code Printer In None
Using Barcode printer for Font Control to generate, create QR-Code image in Font applications.
www.OnBarcode.com
Data: actions, preferences, files, SQLite, and addresses
EAN128 Creation In None
Using Barcode generation for Software Control to generate, create UCC-128 image in Software applications.
www.OnBarcode.com
Drawing Barcode In None
Using Barcode drawer for Office Excel Control to generate, create Barcode image in Office Excel applications.
www.OnBarcode.com
Listing 16.12 Functionality required to call up a new-person view controller
Code 39 Full ASCII Generator In None
Using Barcode printer for Online Control to generate, create ANSI/AIM Code 39 image in Online applications.
www.OnBarcode.com
Make PDF 417 In None
Using Barcode drawer for Online Control to generate, create PDF417 image in Online applications.
www.OnBarcode.com
-(IBAction)newContact:(id)sender { ABNewPersonViewController *myAdder = [[ABNewPersonViewController alloc] init]; myAdder.newPersonViewDelegate = self; UINavigationController *myNav = [[UINavigationController alloc] initWithRootViewController:myAdder]; [self presentModalViewController:myNav animated:YES]; [myAdder release]; [myNav release]; } - (void)newPersonViewController: (ABNewPersonViewController *)newPersonViewController didCompleteWithNewPerson:(ABRecordRef)person { [self dismissModalViewControllerAnimated:YES]; }
Quick Response Code Creation In .NET Framework
Using Barcode drawer for ASP.NET Control to generate, create QR Code JIS X 0510 image in ASP.NET applications.
www.OnBarcode.com
ANSI/AIM Code 39 Reader In C#
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
The other two view controllers work the same way, except for the specifics about what methods each protocol defines. The ABPersonViewController displays the information for a specific user. You ll need to set the displayedPerson property to an ABRecordRef before you call it up. This ABRecordRef might have been retrieved from the Address Book search functions or from the people-picker, using the functions we ve already discussed. The person view controller can optionally be editable. There s one method listed in the protocol, which activates when an individual property is selected. Finally, the ABUnknownPersonViewController allows you to display the ABRecordRef defined by displayedPerson as if it were a real contact. Optionally, the user can create that information as a new contact, add it to an existing contact, or take property-based actions, like calling a number or showing a URL. It s a great way to give users the option to add contact info for your software company to their Address Book. You should now understand the basics of how to use the Address Book in your own programs.
Draw PDF 417 In Visual Basic .NET
Using Barcode generator for VS .NET Control to generate, create PDF 417 image in Visual Studio .NET applications.
www.OnBarcode.com
PDF 417 Decoder In Visual Basic .NET
Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
16.6 Summary
In this chapter, we covered a variety of ways that you can import primarily text-based data into your iPhone program. User action is one of the most important methods, and one well covered by previous sections. Besides the UITextFields, UITextViews, and UISearchBars, there are any number of non-textual interface options. Preferences mark the other major way that users can influence your program. You can either program them manually or use the System Setting bundle. Ultimately, user input is going to be somewhat limited because of the slow typing speed of the iPhone. If you re dealing with piles of text, you more frequently want to pull that data from an existing resource on the iPhone.
Summary
Files are the traditional way to do it. We ll return to files as we deal with photos and sounds in the future. Databases are frequently an easier way to access data, particularly if the data is well organized. Finally, the Address Book gives you a way to share contact information among many different applications, and it even includes its own data entry routines. There s only one data-input method that we ve largely ignored: the internet. We consider that so important for the iPhone that we ll cover it in its own chapter at the end of the book. The data-input and retrieval methods discussed in this chapter will form a foundation for much of the other work you do with the iPhone, because ultimately everything s data. You ll need to retrieve data when you work with images and sounds. Similarly, you may want to save data from your accelerometer, Core Location, or when you ve created a graphic. Keep what you ve learned here in your back pocket as you move on to the rest of the iPhone toolbox. We re now ready to move on to what we expect are two of the most anticipated topics in this book: how to work with the iPhone s accelerometers and its GPS to determine locations.
Copyright © OnBarcode.com . All rights reserved.