Showing posts with label xcode5. Show all posts
Showing posts with label xcode5. Show all posts

Friday, 4 July 2014

PhoneGap & Apache Cordova (Hybrid Mobile Development)


PhoneGap & Apache Cordova

  • Usage: Hybrid mobile development using cross-platform app extensions mixing the native (i.e. iOS SDK platform WebViews) and web-side (i.e. embed Cordova-enabled Cleaver WebView using common JavaScript interface with a iOS Cordova plugin mapping to Objective-C service class) app components to streamline API access
  • HooksNode.js framework (server-side JavaScript) with build process in Apache Cordova Command Line Interface (CLI) using interface server-side hook scripts to automatically install required plugins when developers check out updated versions of a project - Thanks Holly Schinsky!

Challenges

Purchases

Links

Tuesday, 17 June 2014

iOS Sprite Kit Game (Luke's Paddle Tree Game)

Activities @ Lynda - 




Screen Recording in iPhone Simulator


iOS Game Dev with Sprite Kit with Simon Allardice 
    (thanks Lynda for an awesome course!!) DONE
Screenshots of My First Game (Adapted from Copyright Lynda.com Tutorial)
  • GitHub Link: Luke's Breaking Bricks iOS Sprite Kit Game
  • Instructions: 
    • Touch and hold the bottom Paddle to play and prevent it falling. 
    • Move left and right to stop the ball hitting the bottom. 
    • Pause feature activates if you let go of paddle! Touch again to Unpause.
    • Destroy upper bricks to cause Tree to fall down. 
    • Win if Tree touches bottom of screen (tough luck if you deflect it elsewhere haha)
    • Lose if bottom Paddle or Ball touches bottom of screen.
    • Note: The paddle rapidly impulses automatically, so the ball is propelled faster with each contact with the paddle (brace yourself!)
    • Note: Win screen Screenshot not shown (you have to Win to see it!!!), Audio for winning was prepared by yours truly :)
  • Wondering how I preparing the game? It took under 2 days to prepare this game. The purpose of preparing it was to learn iOS Sprite Kit fundamentals programming in Objective-C using Xcode. Most of the code used to prepare the game came from following the Lynda.com course video. I added the following extensions to the game of my own in order to test the framework, but I expended minimal effort in doing so:
    • Custom background (simply a few random coloured brush strokes in Photoshop)
    • Custom sounds (silly 'You Win' and 'You Lose' sounds recorded using Quicktime Player)
    • Custom particle effects (simply replaced the particle effect snow flakes with an image of my head and slightly modified the effect in Particle Effects Editor)
    • Pause feature that activates when use stops touching screen (adapted from this post on Stackoverflow.com). Pause deactivates when the user touches the screen again
    • Tree shaped and coloured object and an animation sequence associated with it. The animation sequence throws the tree it into the screen amongst the bricks at the start of each game. The animation helps it slowly wiggle out of them
    • 'You Win' screen which appears upon contact between the tree object and the bottom of screen (the user may need to destroy the bricks to make it fall)
    • Impulses are automatically applied to the paddle so when the user holds down on the paddle and moves it left and right, the paddle will rapidly spring up and down in this defensive approach, so that each time the ball bounces off the paddle the ball speed increases, which in turn rapidly increases the game difficulty so you can fail or win fast and often! Alternatively an offensive approach can be taken during gameplay if the user chooses to simply hold down on the paddle but does not move left or right, as this will cause the paddle to only rise upward toward the bricks (until the user moves their touch left or right again)
    • If you'd like to know more, please feel free to contact me! Please ensure that you appropriately credit me and the sources I used if you share.

Game Elements 
Scenes (Architecture)
  • Node Types (Sprite, Label, Video, Shape, Emitter, Crop, Effect, etc) 
  • Node Use (manipulable independent Visual Elements Creation and Artwork, Property Configuration, Scene Inclusion, Manipulation, Drawing Order), FPS 
  • Node Association and Inheritance
  • Node Positioning and Coordinate System
    • Anchor Points of Scene and Nodes (Default to Parent Scene)
    • CGPoint (Core Graphics framework) (Explicit and Inline Creation)
  • Physics World (connect and configure different Scene {gravity, zero gravity} and Node Physics Body Properties
    • Physics Bodies (Volume-based (Default is Dynamic Volume or use Static) {simple Draw Path and Play-Testing for complex shapes to minimise Performance impact} , Edge-based). Each one has Bitmask Properties
      • categoryBitMask (Turned On by Default, each Physics Body can belong to multiple Categories and belong to all by Default)
      • collisionBitMask (Turned On by Default, cross-references all Categories where Physics Body should Register a Collision and provide notification of an event)
      • contactBitMask (Turned Off by Default, cross-references all Categories where Physics Body should Register a Contact and provide notification of an event)
    • Physics Body Properties (Mass, Density, Friction {object resistance at collision}, Linear Damping {object resistance moving across space}, Restitution {object bounciness at collision 0 to 1.0f}, Angular Damping, Velocity, etc)
    • Vectors (Magnitude {Force, Impulse}, Direction)
    • Touch Events 
    • Flexibility (Rotation Orientation Compatibility)
    • Collisions (causes them to bounce on impact, and prevents intersection of objects)
    • Contact (apply manually with custom code to be informed when touch detected between objects and apply logic to event)
      • didBeginContact and didEndContact  (reacts to contact using SKPhysicsContactDelegate Protocol)
    • Categories (meaningful Groupings of objects Defined for association with different Physics Body Objects, where Bitmasks are used to describe the actions upon touch between objects of different Categories {inform us, allow or disallow cross-over, bounce, nothing}, 32 Categories allowed to be toggled)
      • Bitwise Operators for defining Multiple Constants for each Categories
    • Landscape Orientation
      • CMD + Right Arrow (in Simulator)
    • Rendering/Game Loop 
      • update method (called at beginning of every frame)
      • didEvaluationActions method (check modifications after Sprite Kit evaluates actions and before any nodes changed are rendered to frame)
      • didSimulatePhysics methods (check mods of Physics Simulation but before affected nodes rendered to screen)
    • Texture Atlases (Manage Artwork Assets for Higher Performance by Grouping images)
      • Animation by Iterating Multiple Images
  • Game Play
    • Scene Transitions (Transition to Second Scene, Win and Lose Scene, Restart First Scene)
    • Sound Effects (SKAction in CAF format)
    • Convert to CAF Format (i.e. M4A from QuickTime Player to CAF Format File)
    • Apple Audio File Convert Tool use by type at Command-Line: 
                /usr/bin/afconvert -f caff -d LEI16 {INPUT} {OUTPUT}
    • Particle Systems (use Small Image and repeat Multiple times)
    • Particle Emitter controls effects under defined Particle Effect Rules using transitioning and Particle Emitter Inheritance to link gradually between nodes
    • Particle Emitter Editor (alternative to creating and setting properties of emitter node object with SKEmitterNode in code, instead simply define properties and save to SKS File for use to create Emitter Nodes)
    • iOS > New File > Resources > Sprite Kit Particle File
    • Actions (SKAction Class)
      • Methods with Reversible Actions
      • Combinations of Sequencing, Grouping, and Repeating Actions
      • Wait Action
  • Refactor 
    • Select Code Snippet > Right Click > Refactor > Extract 
Purchases:
Challenges:
  • Overcoming error "The model used to open the store is incompatible with the one used to create the store”?". 
    • Solution: Delete the SQL file in the apps documents directory
  • Display SQL syntax in Xcode Debugging Area
    • Solution: 
Menu > Product > Scheme > Edit Scheme > Arguments  "-com.apple.CoreData.SQLDebug 1"
  • Discovered how to overcome app always crashing (lost so much time trying to work this out) when attempting to save enum data to core data persistent store. I simply followed this Stackoverflow post from Paras Joshi to reset session and cache data in iPhone Simulator. Absolute lifesaver, this is now my favourite Xcode feature (how sad)!
         Menu > iOS Simulator > Reset Content and Settings

Friday, 23 May 2014

iOS Unit Testing

Challenges
  • Error 'Parse/Parse.h' file not found (Unit Testing in iOS)
    • Background: I added the following Unit Testing lines of code in appropriate sections of my RibbitTests.m file in Xcode 5 to import the view controller header file that I wanted to test.
#import "ImageViewController.h"
@property (nonatomicImageViewController *imageViewController;
#pragma mark - App Test Cases
- (void) testImageViewController{   XCTAssertNotNil(self.imageViewController@"imageViewController model was not nil");}
    • Problem: Received error message 'Parse/Parse.h' file not found 
    • Solution: 
      • Deleted Parse.framework in Xcode 5 (use Apple Finder to check that there is no Parse.framework folder still in your project directory) 
      • Re-downloaded the Parse.com iOS SDK
      • Dragged the downloaded Parse.framework folder into the Frameworks directory within Xcode 5, and ensure that you tick the following boxes (noting that the initial error message you received may have been caused because when you initially installed Parse.com's SDK, you may not have also added a tick next to RibbitTests)
      • Dragged the downloaded Parse.framework folder into the Frameworks directory within Xcode 5, and ensure that you tick the following boxes (noting that the initial error message you received may have been caused because when you initially installed Parse.com's SDK, you may not have also added a tick next to RibbitTests)
Activities @ TeamTreeHouse - 

Unit Testing for iOS (using Xcode 5 IDE) with Amit Bijlani

DONE (using Ribbit iPhone App)
  • Unit Testing { 
    • Runtime errors (insufficient type testing)
    • Logic errors (insufficient scenarios)
    • Regressions (team scenario bugs)
    • XCTest.framework { write tests that a subclasses of XCTestCase }
    • XCT Assertion types
    • Running Unit Tests
      • CMD + U { Product > Tests }
      • Re-Testing { Product > Perform Action > Test Again }
      • Method Testing { Press 'Play' Button in gutter to the left of the method }
    • Navigating Unit Tests
      • Test Navigator (in the Project Navigator)
        • Running Specific Tests { Press 'Play' Button shown on right of: }
          • Test Suite
          • Test Cases
          • Test Methods
    • Creating Tests { Press + Button in bottom left corner of Test Navigator }
      • Test Classes
      • Test Targets
    • Matching Test Case Methods with corresponding Code Methods { Assistant Editor > Click Breadcrumb Navigation bar (at top right), then scroll down and Click either:
      • Test Classes
      • Test Callers { identifies other methods that call the method, including Unit Testing methods }
    • Continuous Integration 
    • Shortcuts 
      • CMD + U  { Runs Unit Test }
      • CMD + Click { Press this combination when hovering a method to toggle between the methods location in the header and implementation files } 

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:

Wednesday, 7 May 2014

Post WDI - iOS Dev App (Web View, Custom Classes, Date Formatting, Dynamic Binding, Super, Self, Segue, View Controller Stack)


Activities @ TeamTreeHouse - 

iOS Development (using Xcode 5 IDE) with Amit Bijlani (Cont'd)

DONE Building API Reader (Table View) iPhone App
  • @synthesise { replace setter and getter methods in .m file associated with @property instance variables in .h file }
  • @interface declaration { NSString *title; } (optional in latest Xcode!)
  • Scoping instance variables { only visible in Class declared within unless use getters and setters }
  • Setter method (in .h) { - (void) setTitle:(NSString *)title; }
  • Getter method (in .h) { - (NSString *) title; }
  • Setter method implementation (in .m, returns instance so use *) { - (void) setTitle:(NSString *)_title { title = _title; }
  • Getter method implementation (in .m) { - (NSString *) title { return title; } }
  • Primitive Type (i.e. int) declaration { @property (nonatomic) int views  } (not require 'strong'/'weak', etc)
  • Legibility Alternative for Primitive Type (Boolean)
.m@property (nonatomic) BOOL unread;
// alternative@property (nonatomic, getter = isUnread) BOOL unread; 

ViewControllerif (blogPost.isUnread) {   NSLog(@"%@", @"hi");}
  • Custom Class instance variable setter access approaches {
    • Dot Notation { NSString *string = blogPost.title; }
    • Convenience Constructor { NSString *string = [blogPost title];
    • Set Method { [blogPost setTitle:@"my title"]; }
  • Self 
    • directly accesses Setter and Getters of the instance variable in @interface
    • allows multiple instance vars to refer to a particular instance of a Class
    • where Class has Parent Class like NSObject, the instance of a Class ('self') needs to refer to the Parent from which it inherits properties and methods (using 'super')
  • Super { refers to Parent Class within implementation }
    • i.e. self = [super init]; // self refers to particular instance of the Class. calls Super/Parent Class to use its methods (i.e. init, dealloc, etc) to initialise instance of Custom Class
  • Customer Class { benefits in that code is more maintainable than with say NSDictionary for data }
  • Dedicated Initializers { responsible to initialize new instances of Class with data, ensures that when a Custom Class is initialized, it must have a title for example }
    • init (NSString, etc)
    • initWithObjects (NSArray, NSDictionary)
    • i.e. - (id) initWithTitle:(NSString *)someTitle;
  • Convenience Constructors { Class methods (i.e. + sign in Help) that performs Alloc and Init in one step and returns an instance }
    • alloc init
    • arrayWithObjects
    • i.e. + (id) blogPostWithTitle:(NSString *)someTitle;  // 'someTitle' passed as argument with this Class method (uses + sign)
  • id { general purpose data type that follows Dynamic Binding Design Pattern where Class of an Instance is not specified immediately (i.e. only definition created in Controller, but it is Bound at Runtime when run app which causes the Object to become a specific type like NSString). it can create instance of any Class and not always know return type. not required to use asterix * (i.e. id *myObject) to indicate instance when specifying 'id', as this is already implied }
  • Dynamic Binding { see above }
  • Display Images from JSON URL { NSURL (i.e. URLWithString) downloaded as UIData (i.e. dataWithContentsOfURL) object (binary), parsed to convert to UIImage object (i.e. imageWithData), and set to the UIImageView (i.e. imageView) }
  • Debugging Malformed and Erroneous Data { i.e. JSON with empty fields ( if ( [blogPost.thumbnail isKindOfClass:[NSString class]] ) { // only display if not NSNull ) }
  • Concatenating Data { [NSString stringWithFormat:@"%@ %@", blogPost.author, blogPost.date]; }
  • Custom Date Styles with NSDateFormatterStyle {
NSDATE *today = [[NSDate alloc] init]; // or use convenience constructor [NSDate date]

NSLog@“%@“, today); // prints today’s date
// NSDate Object stores in ‘seconds’ from Jan 1 2001 until today (represented internally). where 60 sec/min, 60 min/hour, 24 hr/day
NSTimeInterval secondsPerDay = 60 * 60 * 24; // typedef double used with the Date object
NSDate *tomorrow = [NSDate dateWithTimeIntervalSinceNow:secondsPerDay]; // add time to now NSDate *yesterday = [NSDate dateWithTimeIntervalSinceNow:-secondsPerDay]; // minus seconds per day
// create instance of NSDateFormatter NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@“EE MMM, dd”];(see Help Menu "Date Formatting Guide > Date Formatters > Fixed Formats (depends on iOS version)http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns

// pass date object *today through date formatter and output a string NSString *todayString = [dateFormatter stringFromDate:today];
  • URL open in Default Browser
NSURL *url = [NSURL URLWithString:@"http://www.lukeschoen.com"]; UIApplication *application = [UIApplication sharedApplication]; // retrieves shared instance of singleton application object UIApplicationMain (see Support Files > main.m)[application openURL:url]; // call UIApplicationMain's method 'openURL'
  • Navigation Controller { manages presentation of hierarchy of data in app. manages multiple View Controllers and navigation between them. Navigation Controller has following elements:
      • Nav Bar (back button, title)
      • View (custom content)
      • Toobar (optional)
    • View Hierarchy
      • Stack of View Controllers { LIFO (Last In First Out) }
        • viewControllers (NSArray)
      • rootViewController
    • Stack Manipulation
      • Push (View Controller) on Stack (point to same View Controller unless there is a Modal View Controller)
        • Properties set
          • topViewController
          • visibleViewController (points to last one pushed onto the Stack)
  • Link ViewControllers in Storyboard { click Cell, press CTRL and Drag, select say 'push' (push View Controller on the Stack by creating a Segue aka Scene between the View Controllers) }
  • Link & Intercept Segue Event with Code { click Segue (connection between View Controllers), Attributes Inspector > Storyboard Segue > Identifier > "___" (i.e. showBlogPost) }
.h
@property (strong, nonatomic) IBOutlet UIWebView *detailView;@property (strong, nonatomic) NSURL *blogPostURL;
.m (of Master View Controller)

// check 'identifier' given to the segue in the storyboard.    // prepareForSegue is part of UIViewController- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {   NSLog(@"%@",segue.identifier);
// use BlogPost Custom Class (on event where segue for DetailView is fired). DetailViewController (segue object) has @properties 'detailView' and 'blogPostURL' defined if ([[segue identifier] isEqualToString:@"showBlogPost"]) {  // access blogpost object from blogposts array that was selected from Table View       NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];   BlogPost *blogPost = [self.blogPosts objectAtIndex:indexPath.row]; [segue.destinationViewController setBlogPostURL:blogPost.url];

.m (of Detail/Web View Controller)
- (void)viewDidLoad {    [super viewDidLoad];// below refers to @property blogPostURL that was set in Master View Controller to prepare segue and show URL details associated with list itemNSURLRequest *urlRequest = [NSURLRequest requestWithURL:self.blogPostURL]; 
  • WebView { subclass of UIView, uses WebKit rendering engine to display webpages }
  • UIWebView { control dragged to Storyboard and instantiated in code to load webpage by clicking the UIWebView in Assistant Editor, pressing CTRL and dragging the UIWebView from Storyboard to section of code in @interface }
  • Embed WebView and Display Common DetailView (in viewDidLoad method)
NSURL *url = [NSURL URLWithString:@"http://www.lukeschoen.com"]; // create instance of url request    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url]; [self.detailView loadRequest:urlRequest]; // load default webpage using @property detailView

Links:

Purchases: