I phone programming project report


Published on

In this project I had given videos for almost each and every important location of the University of New South Wales. Also the User can know his current location. User can see all the Important Departments, Theatres and Services being provided by the University and see the videos associated to it. Apart from the project the learning of iPhone programming is what has been concentrated.

  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

I phone programming project report

  1. 1. IPhone Programming ProjectUNSW’s Map and Videos7/25/2010The University of New South WalesSupervisor:Dr. Salil KanhereSenior LecturerSchool of Computer Science and EngineeringThe University of New South WalesEmail: salilk@cse.unsw.edu.auSupervisee:Dhara Manojkumar ShahEmail: dhara.shah@student.unsw.edu.auStudent Id: 3299353
  2. 2. IPhone Programming ProjectAcknowledgmentI wish to express my deepest gratitude towards my supervisor Dr. SalilKanhere and PH.D Candidate Kuanlun Huang for their constant supportand motivation which helped me learning and programming IPhone andmaking application for it.Date: - 25th June, 2010 Dhara Shah Student id: - z3299353The University of New South Wales Page 2
  3. 3. IPhone Programming ProjectAbstractIn this project I had given videos for almost each and every importantlocation of the University of New South Wales. Also the User can know hiscurrent location. User can see all the Important Departments, Theatresand Services being provided by the University and see the videosassociated to it. Apart from the project the learning of iPhoneprogramming is what has been concentrated.The University of New South Wales Page 3
  4. 4. IPhone Programming ProjectTable of Contents 1. Introduction..............................................................5 1.1 Motivation......................................................................6 1.2 Technology Overview......................................................7 1.3 Related Work................................................................18 2. System Design........................................................21 2.1 Program Flow................................................................22 2.2 Design Approach...........................................................25 3. Conclusion...............................................................36 3.1 Future Work..................................................................37References....................................................................38The University of New South Wales Page 4
  5. 5. IPhone Programming ProjectChapter 1:- IntroductionIPhone is the upcoming and promising platform available to createapplications which would reach masses. Programming in iPhone is doneusing software development kit of Cocoa.Cocoa has been in the developer’s network since 20-25 years. It’s a veryhigh level platform and a very rich software development kit. It enablesdeveloper to create application with much ease.Model View Controller is the pattern used in programming this project.Model View Controller is much synchronised design pattern.Tools for IPhone programming is Xcode and Interface Builder. Xcode isthe tool used to write the code and Interface Builder enables to design theuser interface of the application. Frameworks are the foundation a genericobject model which allows to modify the classes and UI Kit i.e. Userinterface kit which provides all the touch objects. Language is Objective Cit is a super set of ANSI C with concepts of Object Oriented programming.The University of New South Wales Page 5
  6. 6. IPhone Programming Project1.1 MotivationAs the University of New South Wales are a very renowned and aUniversity having lot of intake of International Students. Due to its hugecampus it is very important that students who are new to it getacquainted to it. This kind of application would be help students to get thefeel of the University even before being there.The University of New South Wales Page 6
  7. 7. IPhone Programming Project1.2 Technology OverviewIPhone is a very popular and powerful tool which inspires to makeapplications in it. IPhone is a phone, iPod and a communication device. Ithas entire MAC OS in it except the UI which instead of Cocoa is cocoatouch. This makes it a very desirable platform to work on as it givesfreedom of building applications with maximum resources and minimumeffort.IPhone OS OverviewIPhone OS comprises the operating system and technologies thatdeveloper use to run applications natively on iPhone and iPod touchdevices. Although it shares a common heritage and many underlyingtechnologies with Mac OS X, iPhone OS was designed to meet the needsof a mobile environment, where user’s needs are slightly different.Existing Mac OS X developers will find many familiar technologies, butthey’ll also find technologies that are available only on iPhone OS, such asthe Multi-Touch interface and accelerometer support.The iPhone SDK contains the code, information, and tools developer needto develop, test, run, debug, and tune applications for the iPhone OS. TheXcode tools have been updated to support development for the iPhoneOS. In addition to providing the basic editing, compilation, and debuggingenvironment for developer code, Xcode also provides the launching pointfor testing developer applications on an iPhone or iPod touch device.Xcode also lets developer run applications in iPhone simulator, a platformthat mimics the basic iPhone OS environment on developer localMacintosh computer.The University of New South Wales Page 7
  8. 8. IPhone Programming ProjectIPhone OS Technology LayersIn iPhone OS, the underlying system architecture, and many of thetechnologies, are similar to those found in Mac OS X. The kernel in iPhoneOS is based on a variant of the same basic Mach kernel that is found inMac OS X. On top of this kernel are the layers of services that are used toimplement applications on the platform. Figure 1-1 shows a high-leveloverview of these layers.Figure 1-1 iPhone OS technology layersThis layering gives developer choices when it comes to implementing thecode. The iPhone SDK supports the creation of graphically-orientedapplications that run natively in iPhone OS. The applications developercreates reside on the user’s Home screen, along with the other systemapplications, such as Photos, Weather, and Clock. After it is launched,The University of New South Wales Page 8
  9. 9. IPhone Programming Projectaside from the kernel and a few low-level daemons, developer applicationis the only application running on the system. While running, developerapplication occupies the entire screen and is the focus of the user’sattention. And when the user presses the Home button, developerapplication quits and the system displays the Home screen again. Havingthe system to developer self is advantageous because it gives developerfull access to the underlying system resources. Developer can takeadvantage of built-in hardware such as the accelerometers, camera, andgraphics hardware to run just developer code.Because the way users interact with iPhone and iPod touch devices isfundamentally different from the way users interact with Mac OS X, theway developer design developer applications must also be different. In aniPhone application, there is no concept of separate document windows fordisplaying content. Instead, all of the application’s data is displayed in asingle window. This has led to the creation of new views and controls thatallow developer to present developer application’s data in an organizedmanner. In addition, many of the standard views and controls maybehave a little differently than their Mac OS X counterparts. Most of thesechanges should be transparent but some may require developer to rethinkthe way developer organize and present developer data.The event-handling model in iPhone OS also represents a significantdeparture from traditional desktop applications. Instead of relying on thetraditional mouse and keyboard events, iPhone OS introduces the idea oftouch events. A touch event can occur at any time and in combinationwith one or more additional touch events. Touches can be used to detectsimple interactions with content, such as selecting or dragging items, orthey can be used to detect complex gestures and interactions, such asswipes or the pinch-open and pinch-close gestures (used, for example, tozoom in and out in the Photos application).Beyond considering the basic structure of developer application, developerneeds to think about how users will actually use it. IPhone applicationsshould be clean, and focused on what the user needs in the moment.Remember that users who are on-the-go want to get at informationquickly and not spend a lot of time looking through several layers ofscreens. Providing a simple layout that highlights the key information theuser needs is important. For games and other fun applications, developershould also consider how the users might want to interact with developerapplication and take advantage of technologies such as theaccelerometers and camera where appropriate.The University of New South Wales Page 9
  10. 10. IPhone Programming ProjectAs developer start development, the frameworks developer wants to useinitially are the Foundation and UIKit frameworks. These frameworksprovide the key services used by all iPhone applications. As developerrefine developer application, developer should investigate the otherframeworks in the system to see what services they offer. Thedocumentation for each framework includes links to relevant conceptualmaterials to help developer learn more about how to use that framework.The University of New South Wales Page 10
  11. 11. IPhone Programming Project Following shows what the above layers constitute of:-The University of New South Wales Page 11
  12. 12. IPhone Programming Project Cocoa Touch Architecture is as follows:-Foundation Framework Details:- Objective – C:-The University of New South Wales Page 12
  13. 13. IPhone Programming ProjectObjective-C extends the standard ANSI C language by providing syntaxfor defining classes, and methods, as well as other constructs thatpromote dynamic extension of classes. Table 1 File extensions for Objective-C code Extension Source type Header files. Header files contain class, type, .h function, and constant declarations. Source files. This is the typical extension used .m for source files and can contain both Objective- C and C code. Source files. A source file with this extension can contain C++ code in addition to Objective-C .mm and C code. This extension should be used only if developer actually refers to C++ classes or features from developer Objective-C code.ClassesAs in most other object-oriented languages, classes in Objective-Cprovide the basic construct for encapsulating some data with the actionsthat operate on that data. An object is a runtime instance of a class, andcontains its own in-memory copy of the instance variables declared bythat class and pointers to the methods of the class.The specification of a class in Objective-C requires two distinct pieces: theinterface and the implementation. The interface portion contains the classdeclaration and defines the instance variables and methods associatedwith the class.The University of New South Wales Page 13
  14. 14. IPhone Programming ProjectThe interface is usually in an .h file. The implementation portion containsthe actual code for the methods of the class. The implementation isusually in an .m file.Figure 1 shows the syntax for declaring a class called MyClass, whichinherits from the NSObject base class. The class declaration always beginswith the @interface compiler directive and ends with the @end directive.Following the class name (and separated from it by a colon) is the nameof the parent class. The instance (or member) variables of the class aredeclared in a code block that is delineated by braces ({and}). Followingthe instance variable block is the list of methods declared by the class. Asemicolon character marks the end of each instance variable and methoddeclaration. Figure 1 A class declarationMethods and MessagingA class in Objective-C can declare two types of methods: instancemethods and class methods. An instance method is a method whoseexecution is scoped to a particular instance of the class. In other words,before developer call an instance method, developer must first create aninstance of the class. Class methods, by comparison, do not requiredeveloper to create an instance, but more on that later.The declaration of a method consists of the method type identifier, areturn type, one or more signature keywords, and the parameter typeand name information.The University of New South Wales Page 14
  15. 15. IPhone Programming ProjectFigure 2 shows the declaration of theinsertObject: atIndex: instancemethod. Figure 2 Method declaration syntaxThis declaration is preceded by a minus (-) sign, which indicates that thisis an instance method. The method’s actual name (insertObject: atIndex:) is a concatenation of all of the signature keywords, including coloncharacters. The colon characters declare the presence of a parameter.When developer wants to call a method, developer does soby messaging an object. A message is the method signature, along withthe parameter information the method needs. All messages developersend to an object are dispatched dynamically, thus facilitating thepolymorphic behaviour of Objective-C classes.Listing 1 shows the implementation of MyClass from the precedingexample. Like the class declaration, the class implementation is identifiedby two compiler directives—here, @implementation and@end. Thesedirectives provide the scoping information the compiler needs to associatethe enclosed methods with the corresponding class. A method’s definitiontherefore matches its corresponding declaration in the interface, exceptfor the inclusion of a code block.The University of New South Wales Page 15
  16. 16. IPhone Programming ProjectListing 1 A class implementation @implementation MyClass - (id)initWithString:(NSString *)aName { if (self = [super init]) { name = [aName copy]; } return self; } + (MyClass *)createMyClassWithString: (NSString *)aName { return [[[self alloc] initWithString:aName] autorelease]; } @endThe University of New South Wales Page 16
  17. 17. IPhone Programming ProjectDeclared PropertiesDeclared properties are a convenience notation used to replace thedeclaration and, optionally, implementation of accessor methods.Developer includes property declarations with the method declarations indeveloper class interface. The basic definition usesthe @property compiler directive, followed by the type information andname of the property. Developer can also configure the property withcustom options, which define how the accessor methods behave. Thefollowing example shows a few simple property declarations: @property BOOL flag; @property (copy) NSString *nameObject; // Copy the object during assignment. @property (readonly) UIView *rootView; // Declare only a getter method.Each readable property specifies a method with the same name as theproperty. Each writable property specifies an additional method of theform setPropertyName: where the first letter of the property name iscapitalized.In developer class implementation, developer can usethe @synthesize compiler directive to ask the compiler to generate themethods according to the specification in the declaration: @synthesize flag; @synthesize nameObject; @synthesize rootView;Developer can combine the @synthesize statements in a single line ifdeveloper wants: @synthesize flag, nameObject, rootView;The University of New South Wales Page 17
  18. 18. IPhone Programming Project1.3 Related WorkFollowing efforts had been made:- 1. I tried to locate places on Google earth and then placing their latitudes and longitudes value on Google maps. As Google allows adding places on the maps if they are not listed. But the problem was as they were not verified they were not uploaded also the Google map kit being used by apple is not the latest one. 2. Also deep study of the map kit and media kit from Apple’s Developer’s Portal was done to understand them properly so that they could be integrated. 3. Hence code was written to capture the latitude and longitude of the location by IPhone. So I went to all the major buildings of the UNSW and captured their geographic coordinates. This was necessary as the coordinates available by Google earth were not accurate as it had altitude factor also added to it and moreover it was a simulation and not exact representation. 4. Next all the videos relevant to the location were taken.The University of New South Wales Page 18
  19. 19. IPhone Programming ProjectCHAPTER 2 System Design Program was designed on the MVC Design based i.e. Model View Controller Design. All the coding was done in Objective C.The University of New South Wales Page 19
  20. 20. IPhone Programming Project2.1 Program FlowFlow of program is as follows:- UI Touch which includes Map, Buttons showing Theatres, Departments and Services. And Switch which let user know its position. Controller decides which class implementation to be invoked As per the class implementation output is presented to the user.The University of New South Wales Page 20
  21. 21. IPhone Programming Project2.2 Design ApproachDesigning had been completed independent and reusable. All theannotations correspond to their respective interfaces which areimplemented in their respective classes.Hence in future if more annotations are required to be implemented theycan be done by simply adding new interfaces and implementing them inclasses.Annotation’s right callout button has been overwritten to show specificvideo regarding that department, services or theatres.Prior their used to be trouble that threads were colliding one showing themap and other showing the video. But with this independent approachboth could be shown without colliding their thread times.The University of New South Wales Page 21
  22. 22. IPhone Programming Project3.0 Conclusion Overall the project gave completely new experience of learning IPhone programming. It made me release that it’s so powerful platform that very powerful applications can be made through it with minimal effort once it’s fully understood. It took me time to understand it properly but the end result was that it could program it very easily and with minimum amount of effort. Had there been more amount of time lot more improvements could have been possible in the application.The University of New South Wales Page 22
  23. 23. IPhone Programming Project3.1 Future WorkFollowing improvements can be made in the application:- 1. Videos can be shown as soon as it is detected near the location. For example if the user is near UNSW Library, application can ask the user if he wishes to play the video of the library. 2. Also right now it covers only UNSW it can be made to cover all Universities across the world. 3. More professionally shoot videos should be integrated showing the insights of the building that would give the user more insight and more wonderful experience rather then only seeing the pictures of the place.The University of New South Wales Page 23
  24. 24. IPhone Programming ProjectReferences 1. http://developer.apple.com/iphone/index.action 2. http://www.stanford.edu/class/cs193p/cgi-bin/drupal/The University of New South Wales Page 24