Monday 21 April 2014

Post WDI - iOS Development, Objective-C (Object-Oriented), C-Programming (Procedural), XCode 5, Cocoa Touch

Activities @ TeamTreeHouse - 

iOS Development (using Xcode 5) with Douglass Turner - 
  • DONE Fundamentals of C (
    • Console Outputs
    • Code Source Files, 
    • Compiler (C Language), 
    • Executables, 
    • 'Include' Statement, 
    • Header Files prepended to Source Files before Build/Run and Conversion to Executable by Compiler, 
    • 'Main' Function entry point to C Programs,
    • Code Blocks and Statements, 
    • Return Types and Values for Functions, 
    • Variables {%d ints, %f floats, %c chars}, 
    • Array Declaration and Initialization, 
    • Operators {specify how variables manipulated}, 
    • Expressions {combine vars creating new values}, 
    • Auto Incrementing before/after Assignment, 
    • Modulus {Long Division Remainder})
  • DONE Functional Programming in C (
    • Control Flow Statements, 
      • For Loops, While and Do While Loops, 
      • If Else Conditional, 
      • Switch Statement Conditional {Comparisons}, 
    • Functions {Declaration, Main Function Use, Implementation}, 
    • Scoping Context Rules and Visibility
  • DONE Objective-C Basics (
    • Pointers to Memory Address, SizeOf, %ld, printf, 
      • Testing Length for Mem Usage Req'd in Bytes, 
      • Pointers '*xxx' Declaration {Tracks Values}, 
      • Pointer to Address '&xxx', 
      • Access/Retrieval De-Referencing Pointer '*xxx', 
      • Structs combined with Functions, 
      • Encapsulation {Well-defined fns with narrow focus to manage tedious programming aspects}) 
  • DONE Intro to Objective-C (
    • Compare Objective-C with Procedural C { 
      • Procedural-C All-in-one-file {typedef, fn, use in main, defined manipulation fns}
      • Objective-C {Object-Oriented Programming OOP} with Class-split-across-two-files {
      • .h header to manipulate class and @interfaces with others as base/super or subclass with instance methods  -(void), params and names associated with params and setters and getters, 
      • .m for background implementation not public}, 
    • C (Struct) VS OOP (Class/Objects)
    • Collections of Classes in Objective-C {NSArray, etc}, 
    • Calling Methods with [ ] {square brackets}, 
    • Allocating Memory {alloc} and Initializing {init}, 
    • @property {simplified setter and getter syntax with details covered by Compiler}, 
    • Inheritance where 'IS A' relationship exists {Base/Super Class with shared methods/properties and Sub Classes/Variations sharing characteristics, changeable in implementation of method or properties, same methods [aka messages] but diff results}, 
    • Composition where get another classes 'state'/'behaviour' / 'properties'/'methods' {want Capabilities of other Class without complexities/details which occurs in Inheritance where become like other Class, i.e. compose Shape with a Button where Button refers to/points to the Shape and gains its functionality}, 
    • Polymorphism 
  • Xcode 5 Shortcuts (CMD + [ --> Un-Indent Code, CMD + ] --> Indent Code)
  • DONE Cocoa Foundation Framework (
    • Objective-C Classes, 
    • Generality Theme of Object-Oriented Programming,
    • 'Init' special methods {i.e. initWithInt}, 
    • NSNumber Class, 
    • %@ to communicate with class to use its 'description' method to display info about it, 
    • Alloc Init (Convenience Constructors) VS
    • Literal Notation (simpler alternative to initialize), 
    • Concatenation {Nesting NSString Methods}, Uppercase, 
    • NSArray (retrieve only Container Class), 
    • NSMutableArray (modifiable generic wrapper Class), 
    • For 'In' Loop (construct 'in' creates local var to lookup array and auto increments code block), 
    • NSDictionary & NSMutableDictionary (collections of Key(unique)/Value pairs), Create using Preexisting Dictionaries) 
  • DONE Advanced Objective-C (
    • C Memory Mgmt {vars using Dynamic Memory} VS 
    • Objective-C Memory Mgmt {Compiler handled}, 
    • Memory Alloc & Free Calls {calls to free memory},
    • Reference Counting Technique of Objective-C {tracking qty of pointers referring to objects in app} Implem. by Compiler and Compiler Hints {from Developer}, 
    • Memory Deallocation when Reference Count is 'nil', 
    • Memory Mgmt Hints {provided via Properties to Compiler} @property(nonatomic{threading}, memory-directive)
    • Memory-Directors {Strong (i.e. parent), Copy (i.e. caters for mutable objects}, Weak (i.e. child), Assign}, Parent-Child Rel'ship (Strong/Weak References), 
    • 'Self' Keyword {refers to Object in context of specific instance of class where method being called}, 
    • 'Super' Keyword {calls implementation defined by Super Class and used to 'Override' their methods}, 
    • Categories {approach to create suites of methods sharing a common theme, it extends Classes by adding convenience methods to existing Classes that do not require Sub Classes to implement them}, 
    • Dynamic Typing {general purpose method capable of handling any type of object from any class using 'ID' data type as generic pointer, does not use * like normal types} 
    • Static Typing {when specifically declare type when create instance}, 
    • Objective-C Dynamic Language {flexibility as will always call the relevant Object on the fly}, 
    • 'Description' Method approach {so make obvious we're using it} NSLog(@"%@", [thing description]);
  • DONE Beyond the Basics 
    • Primitive Data (Scalar) Types { char %c, int %d, unsigned int %u,  long %ld, float %f, double %lf } (ordered by mem size req'd in bytes)
      • Fixed Mem Size (Compiler runtime auto allocates to mem block)
      • Auto Mem Addr Storage
    • Pointers
      • Dynamic Mem
      • Variable Storage
      • Mem Addr (i.e. printf("%p", &i);
      • "Passing by Value" (allocating mem twice for same data passed by reference is resource intensive)
      • Best Practice (Pointers)
        • Store Value Single Mem Location
        • Declare and Pass Pointers to Single Mem Location 
        • (i.e. int i = 100; int *i; i) i outputs mem address 
      • Arrays (Mem Addr points to first mem plus offset)
      • Alloc and Init (inherits from NSObject allowing Mem Mgmt)
        • (i.e. NSNumber *number = [[NSNumber alloc] initWithInt:100]
      • Literal Shorthand (Equivalents)
        • NSNumber *fortyTwo = @42; // performs alloc & init 
        • [NSNumber numberWithInt:42]
      • Compiler Directive (highlights shorthand notation in Objective-C, more readable and maintainable)
        • @ - Directive
        • @"" - NSString
        • @100 - NSNumber
        • @[ ] - NSArray
        • @ { } - NSDictionary
      • C Language Reference Documentation (highlights Equivalent Code Snippets)
      • @property - declaration sets up getters and setters methods
      • (nonatomic, ....) - not multi-threaded  (only one process of reading or writing and no decisions on prioritising access to data for multiple pointing processes
      • (...., strong) - reference for 'retaining' object/property with increasing retain count when property declared
      • (...., weak) - reference when no objection to underlying property being deallocated 
        • Parent Child relationship and referencing parent (self)
      • AFC (automatic reference counting) - previously versions req'd maintenance 
      • Retain Count - increase retain count by perform alloc and init causing an object to point to mem location. additional objects pointing to same mem address causes increase of retain count further (i.e. 2). assign pointer to nil for all pointers reduces retain count to 0 (no objects pointing to mem address) and can deallocate
        • NSLog(@“Retain count is %ld”, CFGetRetainCount((__bridge CFTypeRef)book1)); // where book1 is object retain count displaying
      • 'Retain' Cycle (i.e. Book *book1 = [[Book alloc] init]; book1.me = book1;) - creates retain cycle by 'me' child property of book1 (pointing to its parent). if execute (book1 = nil;) then 'me' property is still pointing to book1 so never releasing memory (Memory Leak caused)
      • Help - Document and API Reference
Activities - Other -


Curiosity

No comments:

Post a Comment