Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MapStack - lesson 0

leveton
March 11, 2016
39

MapStack - lesson 0

leveton

March 11, 2016
Tweet

Transcript

  1. iOS Application > Single View Application Product Name: ‘MapStack’ Organization

    Name: your name Organization id and bundle id: reverse domain of your name Language: Objective-C Uncheck ‘use core data’ and ‘include UI tests’ Check ‘Create a Git Repository’ Creating a new Xcode project
  2. The Run Loop “Run loops are what separates interactive apps

    from command-line tools” - Nicolas Bouilleaud The run loop allows your app to wait for the user to touch the screen before responding. The run loop ‘listens’ for this touch event.
  3. The Run Loop Think of it as a taxi cab

    that circles a city block over and over waiting to pick you up. Or like a Pneumatic tube at a bank drive-through waiting for you to put a message in the tube so it can wisk it away.
  4. The Run Loop There is exactly one run loop for

    each thread. There are six types of events that will cause a run loop to deliver a message. Besides touch events, they can be timers or messages from other apps. The important thing to remember is that the main thread (good old main()) starts an event loop at app launch that ‘listens’ for touch/shake/rotate/tap/etc. events.
  5. The Run Loop The important thing to remember is that

    the main thread (good old main()) starts an event loop at app launch that ‘listens’ for touches/shakes/rotations/taps/etc.
  6. The Lifecycle of an iOS app Info.plist (just XML under

    the hood) for high level app configuration
  7. Object Oriented Programming Concepts Each will have its own slide…

    Methods and Properties Encapsulation Inheritance Polymorphism Introspection Delegation Reference semantics
  8. Methods and properties The methods are what the object does,

    the properties are the things the object has. Some find it easier to think of methods as verbs and properties as nouns. Methods and properties are declared publicly in interface files (.h extension) and privately in implementation files (.m extension). Frameworks will only expose header files so that you only get the info that you need without worrying about implementation (or being able to breach copyright).
  9. Methods and properties Public methods give you access to private

    implementations. This is known as encapsulation...
  10. Encapsulation Objects hide as much information as they can You

    cannot get an object’s data unless that object exposes its data. When you’re a junior developer, your project manager may create just the interface file and have you fill out the implementation details.
  11. Inheritance All classes are descended from other classes except for

    the root class. NSObject -> UIResponder -> AppDelegate -> UIWindow -> UIViewController -> UIView -> UILabel Everything descends from NSObject. All objects are related to NSObject.
  12. Inheritance NSObject -> UIResponder -> AppDelegate -> UIWindow -> UIViewController

    -> UIView -> UILabel These last 3 are what you’ll be working with most of the time. You’ll also spend some time with AppDelegate. UIResponder and UIWindow, not so much.
  13. Polymorphism Objects have ownership of their methods and properties so

    that methods with the same name but different owners can do different things. A Car object and a House object both have a numberOfDoors public property but the runtime doesn’t get confused because of polymorphism
  14. Introspection Objects know about their own abilities Objects have methods

    like isKindOfClass, isMemberOfClass, respondsToSelector, etc. These methods reveal meta info about the object - different from most methods that reveal and manipulate program data or properties.
  15. Delegation from the Apple Docs: “A delegate is an object

    that acts on behalf of, or in coordination with, another object when that object encounters an event in a program.” The delegate pattern so important and popular in Apple land that we’ll be using it and referring back to it throughout the course.
  16. Primitives vs objects Objects are like turbocharged C structs. But

    structs... Rarely have methods Usually have basic inheritance Basic data hiding (encapsulation) that’s error-prone and forced Pseudo-polymorphism.
  17. structs vs objects Structs aren’t used like this is the

    real world. Objects are a better representation of the real world. The biggest difference is that objects have reference semantics as we discussed.
  18. Automatic Reference Counting ARC is how Objective-C manages memory Each

    object on the heap has a retain count. If the retain count reaches 0, the object is deallocated (free() is called under the hood).
  19. Automatic Reference Counting An object that is a local variable

    inside of a function has a retain count of 1 until that function returns. Objects that are ‘owned’ by other objects have a retain count of 1. The more ‘owners’ an object has, the higher its retain count.
  20. Automatic Reference Counting Let’s breakdown this verbose property declaration: @property

    - compiler declaration that our class has an encapsulated value. nonatomic - allocating this property is thread safe - concurrent processing can be done. strong - increments this pointer’s retain count by one . readonly - this datatype can only be accessed via a setter that is implemented by you. nullable - indicates that the pointer can be nil. Contrast this with null_unspecified, nonnull, and null_resettable. <NSString *> - indicates that the elements in the array are of type NSString and are also pointers
  21. atomic vs nonatomic Properties almost always use ‘nonatomic’ storage in

    any project you’ll see. Only projects that deal with multi-threaded environments should use ‘atomic’ storage. Atomic code is treated as a critical section of code and is guaranteed to complete before any other thread gets access to the data inside, because of this safety feature, it is slower to allocate atomic properties.
  22. Xcode crash course Each will get its own slide Navigator

    Main Window Debug area Utilities Devices Organizer
  23. Navigator Project navigator - Files, asset catalogs, xibs, plists, frameworks

    Symbol navigator - Mostly classes Find navigator - Search Issue navigator - Warnings and errors Test navigator - Test files Debug navigator - Debugging Breakpoint navigator - Breakpoints Report navigator - Build, debug, and run logs
  24. Main Window Meta panel - (Shown right, studying this will

    help in understanding OOP) Standard editor - shows one file at a time Assistant editor - defaults to show the header and implementation files Version editor - shows changes since the last commit