Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Introduction of Xcode

Introduction of Xcode will help you to learn iphone application development tool.

  • Soyez le premier à commenter

Introduction of Xcode

  1. 1. Using Xcode
  2. 2. Introduction to XCode • This tutorial will walk you through Xcode, a software development tool for Apple’s iOS applications – We will explore its different parts and their functions – This tutorial will teach you how to use Xcode, but not how to build an app. • To build an app, you need to know Objective- C.
  3. 3. Useful Terms • Objective-C: the programming language used to write iOS applications, based on C and using object oriented programming methods • Object: a collection of code with its data and ways to manipulate that data
  4. 4. Useful Terms • View: how your program presents information to the user • Model: how your data is represented inside of your application
  5. 5. App Templates, Pt 2 Tabbed: Like the iPod app, with lots of different ways to view the same database items Utility: Like the weather app, a main view and a configuration view Empty: You build everything from scratch
  6. 6. Starting an App Choose the name you want for your app Click ‘Next’ Choose a folder in which to save your app Finally, choose your device Writing a universal iOS app is more difficult than writing for just one device
  7. 7. This is what your screen looks like now….
  8. 8. The main parts we’ll be focusing on… 1. Navigator Panel 2. Inspector Panel 3. Libraries
  9. 9. Navigator Panel
  10. 10. The Classes folder contains two objects: - The App Delegate - The View Controller The extensions: - .h = header, defines object - .m= main/body -.xib= XML interface builder
  11. 11. The App Delegate • Handles starting and ending your app • Serves as a go-between between iOS and your app – Hands off control to your code after starting
  12. 12. The View Controller • Handles everything that shows up on screen • Handles all the info that the onscreen objects need to display themselves • Translates between the view and the model • Responds to user input and uses that to change model data – Responsible for updating view from the model
  13. 13. To help visualize… From developer.apple.com
  14. 14. XML Interface Builder This is where you lay out graphic views The view controller knows how to talk to the objects that have been created here Lots of formatting options
  15. 15. Supporting Files, Pt. 1 These are system files .plist = property list Appname-Info.plist = contains info about your app for the iOS. It is an XML file that includes the options you put on your app (which device, etc.) InfoPlist.strings = helps to internationalize your app - Language
  16. 16. Supporting Files, Pt. 2 Main.m = low level. Starts app and gives to the App Delegate. Never change this file. .pch = pre-compiled header Appname-Prefix.pch = generated by the system to speed up builds
  17. 17. Frameworks Frameworks contains a lot of already written code provided by the system - A library of code bits - Related to the Libraries menu on the right of Xcode UIKit = contains code for everything that interfaces with the user (views) Foundation = alll the components used to build the model CoreGraphics = handles drawing on the screen
  18. 18. Inspector Panel • This area contains utilities panels that let you change properties of your app’s view objects, like: • Colors • Sizes • Images • Button actions
  19. 19. Libraries • Different goodies depending on which icon you click – From left to right: • File templates • Code snippets • View Objects • Media/Images
  20. 20. Model, View, Controller (MVC) iOS applications follows the MVC design pattern. • Model: Represents the business logic of your application • View: Represents what the user sees in the device
  21. 21. • Controller: Acts as a mediator between the Model and View. There should not be any direct conversation between the View and the Model. The Controller updates the View based on any changes in the underlying Model. If the user enters or updates any information in the View, the changes are reflected in the Model with the help of the Controller.
  22. 22. How does a View or Model interact with the Controller? • Views can interact with the Controller with the help of targets or delegates. • Whenever the user interacts with a View, for example by touching a button, the View can set the Controller associated with it as the target of the user’s action. Thus the Controller can decide on further actions to be taken. We will see how this can be achieved in the later part of this tutorial. • Views can also delegate some of the actions to the Controller by setting the Controller as its delegate.
  23. 23. MVC
  24. 24. • The Model notifies the Controller of any data changes, and in turn, the Controller updates the data in the Views. The View can then notify the Controller of actions the user performed and the Controller will either update the Model if necessary or retrieve any requested data.
  25. 25. Outlet And Actions Outlet: • ViewController talks to View by using Outlet. Any object (UILabel, UIButton, UIImage, UIView etc) in View can have an Outlet connection to ViewController. Outlet is used as @property in ViewController which means that: • you can set something (like Update UILabel's text, Set background image of a UIView etc.) of an object by using outlet. • you can get something from an object (like current value of UIStepper, current font size of a NSAttributedString etc.)
  26. 26. Action: • View pass on messages about view to ViewController by using Action (Or in technical terms ViewController set itself as Target for any Action in View). Action is a Method in ViewController (unlike Outlet which is @property in ViewController). • Whenever something (any Event) happens to an object (like UIbutton is tapped) then Action pass on message to ViewController. Action (or Action method) can do something after receiving the message. Note: Action can be set only by UIControl's child object; means you can't set Action for UILabel, UIView etc.
  27. 27. Application Life Cycle
  28. 28. • application:willFinishLaunchingWithOp tions: —This method is your app’s first chance to execute code at launch time. • application:didFinishLaunchingWithOp tions: —This method allows you to perform any final initialization before your app is displayed to the user. • applicationDidBecomeActive:—Lets your app know that it is about to become the foreground app. Use this method for any last minute preparation.
  29. 29. • applicationWillResignActive:—Lets you know that your app is transitioning away from being the foreground app. Use this method to put your app into a quiescent state. • applicationDidEnterBackground:—Lets you know that your app is now running in the background and may be suspended at any time. • applicationWillEnterForeground:—Lets you know that your app is moving out of the background and back into the foreground, but that it is not yet active. • applicationWillTerminate:—Lets you know that your app is being terminated. This method is not called if your app is suspended.
  30. 30. Application State • Not running • Inactive • Active • Background • Suspended
  31. 31. View controller • Connect the view and the controller with IBOutlet
  32. 32. View Controller Life Cycle • - (void)viewDidLoad; • -( B(OvoOidL))vaineiwmWatiellAd;ppear: • -( B(OvoOidL))vaineiwmDaitdeAdp; pear: • - (void)viewWillDisappear: (BOOL)animated; • - (void)viewDidDisappear: (BOOL)animated:
  33. 33. UINavigationController • The UINavigationController class implements a specialized view controller that manages the navigation of hierarchical content. This navigation interface makes it possible to present your data efficiently and makes it easier for the user to navigate that content. • A navigation controller object manages the currently displayed screens using the navigation stack
  34. 34. TableView Control • Table View is one of the common UI elements in iOS apps • Most apps, in some ways, make use of Table View to display list of data • The “UITableViewDelegate” and “UITableViewDataSource” are known as protocol in Objective-C. Basically, in order to display data in Table View, we have to conform to the requirements defined in the protocols and implement all the mandatory methods.
  35. 35. UITableViewDelegate • UITableViewDelegate, deals with the appearance of the UITableView. Optional methods of the protocols let you manage the height of a table row, configure section headings and footers, re-order table cells, etc.
  36. 36. UITableViewDataSource • We’ll use the table view to present a list of recipes. So how do you tell UITableView the list of data to display? UITableViewDataSource is the answer. It’s the link between your data and the table view. The UITableViewDataSource protocol declares two required methods • tableView:cellForRowAtIndexPath • tableView:numberOfRowsInSection

×