iPhone External Accessory Programming Exercises

0
iPhone External Accessory Programming ExercisesHere you will find, step-by-step, how you can write iPhone or iPod Touch code, in Objective-C 2.0, to access an external accessory. You will do so by using the ExternalAccessory Framework.

The ExternalAccessory Framework, introduced with iPhone OS 3.0, provides a set of classes so that iPhone and iPod Touch applications can find, and communicate with, external accessories.

An external accessory is a device external to the iPhone or iPod Touch. The external accessory connects to the iPhone or iPod Touch in one of two ways:

1. Using the external connector (the same USB connector you use to charge your device).

2. Using the Bluetooth wireless connection.

The classes that make up the ExternalAccessory framework include:

- EAAccessoryManager. The external accessory manager class. You will use this class to access the external accessory manager.

- EAAccessory. The external accessory class. You will use this class to access the external accessories properties.

- EASession. The external accessory session class. You will use this class to create an input and output stream between your application and the external accessory.

As you will see, there are five major tasks that your application must do to communicate with an external accessory:

1. Gain access to the external accessory manager.
2. Get a list of external accessories from the external accessories manager.
3. Check the accessory properties for each accessory in the list, to find the desired accessory.
4. Create a session with a specific protocol with the accessory.
5. Stream data to/from the accessory.

How can you learn to write external accessory code before having access to an actual external accessory? The answer is that the iPhone simulator includes a simulation of two external accessories, hence you can perform the exercises here even if you do not have access to a real external accessory.

CONTENTS

0. Introduction
1. Step 1. Create New Xcode Project
2. Step 2. Add Framework Header File
3. Step 3. Add Framework Reference
4. Step 4. Access EAAccessoryManager
5. Step 5. Get Array of Connected Accessories
6. Step 6. Display Accessory Properties
7. Step 7. Handle Accessory Disconnect
8. Step 8. Create EASession Object
9. Step 9. Use NSOutputStream
10. Step 10. Use NSInputStream
11. Final Code Listing
12. Skills Review

Price: $4.95


Click here to buy from Amazon


This post was made using the Auto Blogging Software from WebMagnates.org This line will not appear when posts are made after activating the software to full version.