iPhone Programming
Speaker Arun Chhetri
What is iPhone
• Smart Phone by Apple.
• Why is iPhone an iPhone, not just Phone ??????
• • • • • • • • • Built in Accelerometer GPS or Position Triangulation Multi Touch Interface Sensors Keyboard Safari Mail Calendar Wide Screen Display
» I think biggest in the market
What do u need to Program for iPhone
• To buy MAC
iPhone Overview
• Smart Phone • iPod (Widescreen) • Wireless Internet Communication Device
• Wifi 802.11 b/g
• • • • • •
PDA Computer (OS X) Camera Multi-Touch interface GPS App Store
iPhone Development
• • • • Development done with the help of iPhone SDK Uses Objective-C IDE XCODE Only push your application through App Store
• 99 $ membership • Review of your application
» Code also
• 70 % and 30 % share.
iPhone SDK
• iPhone Sdk have five powerful tools to do iPhone programming.
1. XCODE • Professional text editor • Debugger • GCC compiler 2. Interface Builder • For creating user interface 3. Instruments • For optimizing application 4. Dash Code • For creating web applications for Safari 5. iPhone Simulator
Things to consider before programming
• Low resources
• 128 mb Ram • Limited Battery life • Application should take less execution time. • Exceptional Handling • Multi Touch Events
iPhone OS overview and Technologies
iPhone Os can be viewed as set of layers
Cocoa Touch Layer
• The Cocoa Touch layer comprises the UIKit and Foundation frameworks (UIKit.framework and Foundation.framework), which provide the basic tools and infrastructure you need to implement graphical, event-driven applications in iPhone OS iPhone OS uses this layer to implement features:
– – – – – – – – – – Application management Graphics and windowing support Event-handling support User interface management Objects representing the standard system views and controls Support for text and web content Accelerometer data The built-in camera The user’s photo library Device-specific information
•
Media Layer
• • The Media layer provides graphics and media technologies in iPhone OS that are geared toward creating most advanced multimedia experience on a mobile device Graphics Technologies – technologies to do your 2D and 3D drawing – OpenGLES.framework (OpenGL), EAGL.framework, QuartzCore.framework (Core Animation), CoreGraphics.framework (Quartz) Core Audio – Native support for audio is provided by the Core Audio family of frameworks – CoreAudio.framework (audio type and file info), AudioToolbox.framework (playback and recording), AudioUnit.framework (audio processing) OpenAL – The Open Audio Library (OpenAL) interface is a cross-platform standard for delivering 3D audio in applications Video Technologies – iPhone OS provides support for full-screen video playback through the Media Player framework (MediaPlayer.framework) – supports the playback of movie files with the .mov, .mp4, .m4v, and .3gp filename extensions
•
•
•
Core Services
• • The Core Services layer provides the fundamental system services that all applications use Address Book – AddressBook.framework: provides programmatic access to the contacts stored on a user’s device – AddressBookUI.framework: complements the Address Book framework by providing a graphical interface for accessing the user’s contacts Core Location – CoreLocation.framework: lets you determine the current latitude and longitude of a device CFNetwork – CFNetwork.framework: high-performance, C-based framework that provides a set of object-oriented abstractions for working with network protocols, for tasks such as communicating with FTP and HTTP servers or resolving DNS hosts Security – Security.framework: provides interfaces for managing certificates, public and private keys, and trust policies SQLite – The SQLite library lets you embed a lightweight SQL database into your application without running a separate remote database server process – From your application, you can create local database files and manage the tables and records in those files
• •
•
•
Core OS
• The Core OS layer encompasses the kernel environment, drivers, and basic interfaces of the operating system
• iPhone OS provides a set of interfaces for accessing many low-level features of the operating system. Your application accesses these features through the LibSystem library. The interfaces are C-based and provide support for the following: – Threading (POSIX threads) – Networking (BSD sockets) – File-system access – Standard I/O – Bonjour and DNS services – Locale information – Memory allocation
iPhone Hardware and Software features that can be incorporated in applications
• Accelerometer – iPhone and iPod touch have 3 accelerometers to measure changes along each of the primary axes in three-dimensional space, which allows you to detect motion in any direction – The system uses the accelerometers to monitor a device’s current orientation and to notify applications when that orientation changes – Applications that want to access the accelerometer data directly can also do so using UIKit
iPhone Hardware and Software features that can be incorporated in applications
• Core Location – The Core Location framework monitors signals coming from cell phone towers and Wi-Fi hotspots and uses them to triangulate the user’s current position – You can specify the desired accuracy of the location information, and threshold for reporting changes in the current location – Use this framework judiciously to not drain the user’s battery
iPhone Hardware and Software features that can be incorporated in applications
• Contacts – The Phone, Mail, and SMS Text applications use user’s list of contacts to identify people the user needs to contact and to facilitate basic interactions such as starting a phone call, email, or text message – Your own applications can access this list of contacts for similar purposes or to get other information relevant to your application’s needs – You can access the user’s contact information using the Address Book UI framework
iPhone Hardware and Software features that can be incorporated in applications
• The Camera and Photo Library – iPhone has an inbuilt camera as well as a centralized photo library whereas iPod Touch doesn’t have a camera – iPhone OS provides access to both of these features through classes in the UIKit framework – You can incorporate system-provided picker interfaces into your application – These interfaces provide standard system views for selecting a photo from the user’s photo library or taking a picture using the camera
Styles of Programming for iPhone
• iPhone OS defines three basic styles for applications:
• Productivity style • Utility style • Immersive style
Productive Style
• Productivity Applications – The focus is on the organization and manipulation of detailed information – Information is usually text-based, but may also be image based if the content is more visually oriented – Tend to be use multiple screens and make use of system controls to handle the navigation from screen to screen – Typically rely on system views and controls (text fields, labels, and other data-oriented views) for their presentation and do little or no custom drawing – Example: The Settings application
Utility Style
• Utility Applications – Perform a targeted task that requires relatively little user input – A quick summary of information or a simple task on a small number of objects – Interface should be a visually appealing and uncluttered to make it easier to spot the needed information quickly – Use of appropriate graphics to have a pleasing visual appearance – Examples: Weather and Stocks applications
Immersive Application
• Immersive Applications – Offer a full-screen, visually rich environment that’s focused on the content and the user’s experience with that content – Commonly used for implementing games and multimedia-centric applications – Often present custom interfaces, and relies less on standard system views and controls – Typically use OpenGL ES to draw content, because it provides good performance for full-screen content at high frame rates – Example: Media Player application
Our Project
• iRobotController
• Control Remote Devices through iPhone. • Remote Device has a CAM which relays live stream to iPhone
iRobotController
On Remote Device Side • Install linux on the remote device. • Write Device Controller.
• Written in Python.
• Make an ad-hoc network on that device that has to be controlled. • Write a demon on remote device that listen to particular port for e.g. 7080. • Receives XML, parse it and get the command, then execute the command. • Capture live video through cam and then relay it to iPhone.
iRobotController
• • • • On iPhone Side Connect iPhone to the ad-hoc network. Get the Accelerometer and touch interface readings. Create XML, and send to that particular remote device. Receives live stream and then display it on screen.
Thanks