1 / 58

Mobile Apps Programming

Mobile Apps Programming. Chin-Sung Lin Eleanor Roosevelt High School. Mobile Apps Programming. Mobile Platforms Mobile Programming Tools Objective-C Language iPhone Apps Development Architecture iPhone App – Elro Movie Channel iPhone App – Quadratic Calculator

ting
Download Presentation

Mobile Apps Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mobile Apps Programming Chin-Sung Lin Eleanor Roosevelt High School

  2. Mobile Apps Programming • Mobile Platforms • Mobile Programming Tools • Objective-C Language • iPhone Apps Development Architecture • iPhone App – Elro Movie Channel • iPhone App – Quadratic Calculator • iPhone App – Music Library • iPhone App – Elro Student App • iPhone App – Super Mario Bros. Maze Game • iPhone App – Light Balls Game

  3. MobilePlatforms

  4. MobilePlatforms 3 Major Mobile Platforms • iOS Platform • Windows Phone Platform • Android Platform 81.3% 4.1% 13.4% Q3 2013

  5. MobilePlatforms Mobile Platform Architecture • Application – the layer users interact with. • Core Libraries – the layer provides device functionality the developers use to create apps. • Operating System – the layer translates programs into machine language. • Hardware – the layer is the physical device. Application Core Libraries Operating System Hardware

  6. iOS 7 MobilePlatform • iOS 7 is the 7th major release of the iOS mobile operating system. It was released on 09/18/2013. • Support iPhone, iPod Touch, iPad, iPadMini, and second-generation Apple TV. • iOS7 includes a redesigned user interface and numerous functionality changes. • As of 12/2013, iOS 7 has been installed on 78% of supported devices. • As of 10/2013, Apple's App Store contained more than 1 million iOS applications, 475,000 of which were optimised for iPad. These apps have collectively been downloaded more than 60 billion times.

  7. Mobile Device Features • Internet access • Touch screen • GPS (Global Positioning System – satellite-based system to determine a location) • Local storage • Camera • Media playback • Phone • Bluetooth for device communication

  8. Mobile Device Limitations • Screen size • No physical keyboard or trackball – a finger or stylus is the primary interface to the device • Memory • Storage • Battery Life • Cell network • Sometimes flaky networks

  9. MobileProgramming Tools

  10. MobileDeveloper Programs Registered Apple Developer • Free to access Apple developer tools and resources for creating iOS and Mac apps, including Xcode, WWDC videos, sample code, and more. • Web Address: https://developer.apple.com/register/index.action iOS Developer Program • Test your apps on devices and distribute your apps on the App Store • $99 / year • Web Address: https://developer.apple.com/programs/ios/

  11. Xcode 5 & iOS 7 SDk • Xcodeis an integrated development environment (IDE) containing a suite of software development tools developed by Apple for developing software for OS X and iOS. • Xcode provides an interface to the compiler, editor, interface builder, debugger, simulator and code profiling tools. • Available for free from the App Store

  12. Xcode 5 IDE

  13. Xcode 5 Simulator Simulator • Simulates various features of a real iOSdevice. Limitations • Making Phone calls • Accessing the Accelerometer/Gyroscope • Sending and Receiving SMS messages • Installing applications from the App Store • Accessibility to the Camera • Use of the Microphone • Several Core OpenGL ES Features

  14. Xcode 5 Instruments • A performance, analysis, and testing tool for dynamically tracing and profiling OS X and iOS code. • A flexible and powerful tool that lets you track one or more processes and examine the collected data. • Helps you understand the behavior of both user apps and the operating system. • Monitor your applications for memory leaks, which can cause unexpected results. • Gain a deeper understanding of the execution behavior of your applications.

  15. Xcode 5 Instruments

  16. Objective-C Language

  17. Objective-CLanguage • An Object Oriented Programming (OOP) language. • Objective-C builds on top of C, and is a superset of C. • Objective-C is the primary programming language used for programming iOS devices.

  18. Objective-CLanguage Basics • Data Types • Data Types – Signed and Unsigned • Arithmetic Operators • Logic Operators • Compound Assignment Operators • Comparison Operators • Flow Control Statements • Looping Statements

  19. Objective-CLanguage Basics Data Types • int: integer, 4 bytes • unsigned int: unsigned integer, 4 bytes • float: floating point number, 4 bytes • double: double precision, 8 bytes • char: character, 1 byte • string: string, depends on number of characters • bool: Boolean

  20. Objective-CLanguage Basics Data Types – Signed and Unsigned • int –-2,147,483,647 up to 2,147,483,647 • signed– default of all variable types • unsigned– maximum number 4,294,967,294

  21. Objective-CLanguage Basics Arithmetic Operators • - (unary): negates the value of a variable or expression • +: addition • -: subtraction • *: multiplication • /: division • %: modulo

  22. Objective-CLanguage Basics Logic Operators • NOT (!): inverts the current value of a Boolean variable. • AND (&&): return true if both of the two operands evaluated to be true. • OR (||): return true if at least one of the two operands evaluated to be true. • XOR (^): return true if one and only one of the two operands evaluated to be true. • Ternary/Conditional Operator ([condition] ? [true expression] : [false expression]): if [condition] is true, the [true expression] will be evaluated; if [condition] is false, the [false expression] will be evaluated.

  23. Objective-CLanguage Basics Compound Assignment Operators • x += y: add x to y and place result in x • x -= y: subtract y from x and place result in x • x *= y: multiply x by y and place result in x • x /= y: divide x by y and place result in x • x %= y: perform modulo on x and y and place result in x • x &= y: assign to x the result of logical AND operation on x and y • x |= y: assign to x the result of logical OR operation on x and y • x ^= y: assign to x the result of logical XOR operation on x and y

  24. Objective-CLanguage Basics Comparison Operators • x == y: return true if x is equal to y • x != y: return true if x is not equal to y • x > y: return true if x is greater than y • x >= y: return true if x is greater than or equal to y • x < y: return true if x is less than y • x <= y: return true if x is less than or equal to y

  25. Objective-CLanguage Basics Flow Control Statements with if and else • if (Boolean expression) { statements; } • if (Boolean expression) { statements; } else { statements; } • if (Boolean expression) { statements; } else if { statements; } ………… • if (Boolean expression) { statements; } else if { statements; } ………… else { statements; } • Braces ({ }) are required if more than one statement is executed after the if/else.

  26. Objective-CLanguage Basics Looping Statements • for loop: for ([initializer]; [conditional expression]; [loop expression]) {statements;} • while loop: while ( [conditional expression]) {statements;} • do... while loop: do {statements;} while ( [conditional expression]) • Braces ({ }) are required if more than one statement is executed after the if/else.

  27. Objectsand Classes Objects • Objects are based on the objects in the real world. • Objectsare self-contained modules of functionality that can be easily used, and reused as the building blocks for a software application. • Objectsconsist of data variables and functions (called methods) that can be accessed and called on the object to perform tasks.

  28. Objectsand Classes Classes • Objects of the same kind are said to be members of the same Class. All members of a Classare able to perform the same methods and have matching sets of instance variables. They also share a common definition. • A Classdefines what an Object will look like when it is created. • A Classdefines what the Methods will do and what Instance Variables will be.

  29. Objectsand Classes Creating New Classes • First need to declare it using an interfaceand then define it using an implementation. The declaration(.h) and the definition(.m) are usually written in two separate files. • Both the declaration and the definition parts use compiler directives. A compiler directive is an instruction to the Objective-C compiler prefixed by the @ sign. The declaration is signaled to the compiler using the @interface directive, while the definitionis signaled using the @implementation directive.

  30. Objectsand Classes Creating New Classes – Declaration • A new class MyClassNameis declared and is a subclass of the MyParentClassNameclass. @interface MyClassName : MyParentClassName { // attribute declarations: (instance variables) } // method declarations @end

  31. Objectsand Classes Creating New Classes – Declaring Instance Variables • Data Encapsulation: Data should be stored within classes and accessed only through methods defined in that class. • Data encapsulated in a class are referred to as instance variables (ivars). • Instance Variables are declared in the same way any other variables are declared in Objective-C.

  32. Objectsand Classes Creating New Classes – Declaring Instance Variables • Two new instance variables of class MyClassName are declared between the braces. @interface MyClassName : MyParentClassName { intfirstVar; intsecondVar; } // method declarations @end

  33. Objectsand Classes Creating New Classes – Defining Instance Methods • Methods: The methods of a class are code routines that can be called upon to perform specific tasks within the context of an instance of that class. • Methods come in two different forms, class methods (preceded by +) and instance methods (preceded by -) . • Class methodsoperate at the level of the classsuch as creating a new instance of a class. • Instance methods operate only on the instance of the class.

  34. Objectsand Classes Creating New Classes – Defining Instance Methods • Data Type of Methods: • If a method returns a result, the name of the method must be preceded by the data type returned enclosed in parentheses. • If a methoddoes not return a result, then the method must be declared as void. • Arguments of Methods: If data (called arguments) needs to be passed through to a method, the method name is followed by a colon, the data type in parentheses, and a name for the argument. • Methods may accept more than one arguments.

  35. Objectsand Classes Creating New Classes – Defining Instance Methods • Three new instance methods of class MyClassName are declared between the closing brace and @end. @interface MyClassName : MyParentClassName { intfirstVar; intsecondVar; } - (void) setMyClass: (int) x andNext: (int) y; - (int) addVariables; - (void) displayVarSum; @end

  36. Objectsand Classes Creating New Classes – Declaring Class Implementation • Method Implementation: write the code for the methods we have declared earlier in the @interface section of the class declaration (.h). • Methods are implemented in the @implementation section of the class definition (.m).

  37. Objectsand Classes Creating New Classes – Declaring Class Implementation Two methods of class MyClassName are implemented in the @implementation section of the MyClassName.m file. #import “MyClassName.h” @implementation MyClassName - (void) setMyClass: (int) x andNext: (int) y; { firstVar = x; secondVar = y; }

  38. Objectsand Classes Creating New Classes – Declaring Class Implementation - (int) addVariables; { return firstVar + secondVar; } - (void) displayVariable: (int) x; { NSLog(@”Variable value = %i and %d” firstVar, secondVar ; } @end

  39. iPhone Apps Development Architecture

  40. Mobile Apps Development Architecture A few fundamental design patterns that form the development architecture of any apps. • Model-View-Controller—governs the overall structure of your app. • Target-Action— translates user interactions with buttons and controls into code that your app can execute. • Subclassing— creates new classes from an existing class and extends the functionality. • Delegation— facilitates the transfer information and data from one object to another.

  41. Mobile Apps Development Architecture Model-View-Controller • Separating user interface from application logic and data handling. • Model-View-Controller (MVC) methodology increases reusability. • MVC is the paradigm of iOSprogramming. • Model: Hold data, should know nothing of the interface. • View: code for getting data in/out of a view. Deals with items like buttons, lists, tables, etc. • Controller: keeps the Model objects and View objects in sync. • Model, Viewand Controller are objects.

  42. Mobile Apps Development Architecture • A view controller object interacts with model through Methods and Properties exposed by the Model object. • A view controller object interacts with view through Target-Action pattern, together with Outlets and Actions.

  43. Model-View-Controller

  44. Mobile Apps Development Architecture Target-Action pattern, IBOutlets and IBActions • A view controller object interacts with view through Target-Action pattern, together with Outlets and Actions. • Target-Action connects the triggered events in the user interface to the specific methods in the view controller using actions. • An Action is a method defined within a view controller object that is designed to be called when an event is triggered in a view object. • The opposite of an Action is the Outlet. • An Outlet allows a view controller object method to directly access the properties of a view object.

  45. Mobile Apps Development Architecture Subclassing • A major feature of an Objective-Oriented Programming environment. • The new class inherits all the functionality of the parent class combined with the additional new methods and properties. • Ex: UIViewController is a generic view controller from which we will create a subclass so that we can add our own methods and properties.

  46. Mobile Apps Development Architecture Delegation • Allows an object to pass the responsibility for performing one or more tasks onto another object. • Allows the behavior of an object to be modified without having to go through the process of subclassing it. • Ex: UIApplicationdelegates the applicationDidFinishLaunchingWithOptions: method to us so that we can write code to perform specific tasks when the app first loads.

  47. iPhone AppELRO Movie Channel

  48. ELRO Movie Channel

  49. iPhone AppQuadratic Calculator

  50. Quadratic Calculator

More Related