Monday 12 May 2014

Post WDI - iOS Dev App (User Accounts, BaaS, Mobile Design, Parse.com Framework API, Asynchronous, Helper Methods, Git Ignore, RubyMotion)

Challenges
  • Debugged extensively trying to solve why checkmarks were appearing on currently selected cells in the table view only after clicking another different cell in the table view 
    • Solution: Incorrect method chosen when creating instance method with autocomplete, should have used didSelectRowAtIndexPath (NOT 
      didDeselectRowAtIndexPath)
Activities @ TeamTreeHouse - 

iOS Development (using Xcode 5 IDE) with Ben Jakuben

DONE Ribbit iPhone App
  • Xcode 5 Tabs for Open Files { Xcode5  > Preferences > Navigation > Double Click > Use Separate Tab }
  • View Controller Lifecycle 
    • Start App (First Time)
      1. view not exist
      2. call viewDidLoad (only called if no view controller exists in memory)
      3. call viewWillAppear 
      4. call viewDidAppear
      5. view controller appears on screen in ready state (user can view and interact)
    • Navigating Away from current ViewController
      1. call viewWillDisappear
      2. call viewDidDisappear
      3. view controller remains in memory for future use as long as memory avail
    • Start App (After First Time)
      1. skips viewDidLoad (as it already exists)
      2. call viewWillAppear
      3. call viewDidAppear
    • Typical Usage
      • viewDidLoad { use for code that only needs to run once when view first loaded (i.e. creating, loading data, config display) }
      • viewWillAppear { use to display something every time view controller displays on screen (i.e. refresh data, animation) }
  • Stack (of View Controllers) (Nav Controller maintains VC's pushed onto or pulled off the array stack above Root VC)
    • pushViewController
    • popViewController
  • Import Types (used in Header file)
    • " "   means search current project for header file
    • < >  means search certain present system paths (i.e. frameworks)
  • UITabBarController (switches between different tab areas of app) UITabBarItem
    • selectedIndex property
    • setSelectedIndex
    • badgeValue property
  • UIAlertView { [alertView show] }
  • UITableViewCellAccessoryCheckmark (or None)
    • accessoryType 
    • Prevent Scrolling Cell Reuse { explicitly set each cell only when user corresponding to current table view row is in an array to prevent reuse of cells and incorrectly mirrored checkmarks being displayed }
  • UIImagePickerController (capturing photos and videos with either Default (presented modally) or Customer implementation type )
    • Protocols { Custom View Controller created in conformance with UIImagePickerController delegate, which in turn conforms to UINavigationController delegate protocol, so when user cancels or captures images or video the system notifies the cameras delegate of the users choice }
    • presentViewController used to display the the camera view modally
    • imagePickerControllerDidCancel { delegate method of UIImagePickerController where Custom Class that we've named 'CameraViewController' is the delegate }
    • didFinishPickingMediaWithInfo { stores image info in NSDictionary with a key }
    • UIImagePickerControllerMediaType { key method constant passed in and used to retrieve different media types stored as constants as part of Mobile Core Services Framework }
      • #import <MobileCoreServices/UTCoreTypes.h> (constant values of media types obtained)
      • kUTTypeImage { image media type from Core Foundation (CF) that needs to be converted to Next Step (NS) String counterpart type of data structure using Cast (NSString *). use @properties to store images retrieved for use throughout view controller and to set it to be stored in NSDictionary key }
    • UIImagePickerControllerMediaURL { key path method constant passed in and used to retrieve local iOS internal path as a string and stored in @property defined in header (videos not stored in NSDictionary like images are) }
    • Simulator Testing with Photo Album (the iPhone camera is not available unless testing using the device so to test within the simulator using the photo album instead perform the following actions in Xcode Simulator)
      • Hardware > Home, Open Safari in Simulator, Drag a photo to Safari browser, Click the 'Share' button, Click 'Save to Camera Roll'
    • Help Menu Keywords { camera programming topics for iOS }
  • Video Player 
    • Options on iPhone
      • Default Video Player (MPMoviePlayerController)
      • Embedded Video Player
    • #import <MediaPlayer/MediaPlayer.h>
    • Media Player Framework (MediaPlayer.framework)
      • Project > Build Phases > Link Binary Libraries
  • NSTimer 
    • scheduleTimerWithTimeInterval
  • Testing 
    • respondsToSelector (check if method exists before calling it in code block)
  • Modal Control Dfn { UI of VC requiring user input before proceed with app }
    • Modal View Controller { layer over current VC, child of current VC (i.e. UIAlertView) } 
  • NavigationController (NavC) (help navigate different sections of app screen flow)
    • Set NavC for the TableVC and TabBarC { pairs NavCs with TabBarController and used to control the Manual Segues with VC, Click VC, Menu > Embed In > Navigation Controller  }
      • popToRootViewControllerAnimated
      • Remove Default Back Button Setup by NavC { self.navigationItem.hidesBackButton = YES; }
      • Remove Tab Bar  { Add method to prepareForSegue setHideBottomBarWhenPushed before VC pushed onto the stack of the workflow 
  • Segue (With)
    • VC onto NavC { CTRL+click, Drag to ViewController(VC), select Action Segue }
    • Button to VC { CTRL+click button, Drag to VC, select Action Segue }
  • Segue (Without)
    • VC onto TableVC { access VC without Segue attached to Action, CTRL+click 'yellow icon' below VC, Drag to VC, select Manual Segue }
  • Segue (Identifier)
    • Click Segue between VC, Add "Identifier" to pass Data between VCs
    • Create method to perform segue to second view controller { -(void)___ { [self perfomSegueWithIdentifier:@"<insert identifier>" sender:self]; }
  • Linking the Prototype Cell of VC in Storyboard with Class Method (Attributes Inspector > Identifier > "Cell", to match CellIdentifier in code) 
  • @property Storage { Data Source 'Weak' for Text Fields on Sign Up and Sign In forms as dependent on life of View Controller itself }
  • IBOutlet { used for Text Fields for user input, dragged to @interface using Assistant Editor View }
  • IBAction { used for Button to submit, dragged to @interface }
  • Refactoring Code { Select code for refactoring (encapsulating into separate method to comply with DRY principle) into a new Helper method and then go to Edit > Refactor > Extract > <enter name for method> 
  • Stub { i.e. - (void)___ { } }
  • API  { Application Programming Interface to interact with sub systems and third party systems i.e. UIKit and Foundation frameworks }
  • Black Box { System designed with Interfaces (i.e. sets of methods and properties defined in publicly viewable header file) clearly defined between components }
  • Web Interface { between Front-End Black Box and Back-End (i.e. Parse.com Back-end-as-a-Service (BaaS) dynamically creates what is needed in Back-End) }
  • Parse.com Framework SDK Setup { extra Frameworks required as Dependencies by Parse Framework installed per Parse.com instructions via Project > Target (Ribbit) > Build Phases (tab) > Click “Link Binary with Libraries” }
  • Parse.com API Calls { iOS Guide, iOS API
    • objectWithClassName (PFObject) (creates Parse.com database table object) saveInBackground (save data to Parse.com back-end)
    • signUpInBackgroundWithBlock (PFUser) (asynchronous multi threaded approach using Block construct set up as callback mechanism with Parse.com response, receipt and processing in block with success and error handling)
    • currentUser (PFUser) (returned value is automatically Cached on device and user session logged in)
    • logOut (PFUser)
    • loginHandler block (PFUser)
    • loginWithUsernameInBackground (PFUser)
    • findObjectsInBackgroundWithBlock (PFQuery) (block that returns array of PFObjects)
    • relationForKey (PFRelation)
    • saveInBackgroundWithBlock 
    • reloadData (method to refresh the Table View data)
    • addObject
    • saveInBackground
  • Parse.com Classes { 
    • PFObject (iOS Guide > Users)
    • PFUser
    • PFRelation  (ensures Parse.com not dealing with too much Data at once. Relations are stored in Parse.com Table Object under column (property of Class) with designated Key. PFRelation has a PFQuery property to use to retrieve data linked by relation)
    • PFQuery (retrieving and viewing data 
    • PFFile (uploading files and associate them with a message PFObject that will be )
  • Uploading Files to Parse.com
    • PFFile to upload file itself
    • PFObject uploaded separately as message Object (created dynamically at Parse.com) associated with PFFile
      • Message Object 
        • Message Contents
        • Sender
        • Recipient
      • Schemaless means not req'd to specify keys existing on each PFObject, just set KV pair and back-end stores them
    • Chaining Asynchronous Calls { upload file itself and then other details if initial asynchronous call succeeded improves UX by not delaying user }
  • Deleting Files on Parse.com
    • Options
      • RESTful API's 
      • Clean Up Files (Dashboard > Settings > Clean Up Files) { deletes all files that we have uploaded that are no longer referenced by any other objects in back-end }
  • Asynchronous Indeterminant Nature (amount of Time) of calls as data not always returned in order expected. Multiple Callback Blocks must be managed. Avoid where possible by implementing DRY principle and sharing data between methods of VC's with prepareForSegue method
  • Block { ^ (<parameters defined inside parenthesise>) { curly braces with code } }
  • Helper Methods (i.e. looping mechanism to check for friends against current user)
    • Alternative is Hash or Cache for efficiency with high volume of users 
  • Shortcuts 
    • Hidden Files (show hidden files with CMD + Shift + . }
    • Indentation CMD + ]  or CMD + [
  • Git Ignore { store API keys in .plist file using this guide https://teamtreehouse.com/forum/hiding-api-credentials-in-github-for-xcode-5-projects }
  • Mobile Design

Events:
  • ATTENDED SydInMotion - Ruby & iOS development (awesome! early stage community)
    • @fluffyjack (inspiring presentation, RubyInMotion time after exams finish mid June '14)

Curiosity:

Purchases:
  • RubyMotion a personal leap of faith inspired by SydInMotion! Now I just need to buy some coding friends...

Links:

No comments:

Post a Comment