Giter Club home page Giter Club logo

recipes's Introduction

Recipe Program

This project is from iOS SDK Programming by Chris Adamson and Bill Dudney. Beta 2.

Chapter 4 View Controllers

This is the introduction to the Recipe application. Chapter 4 sets up the basic application and illustrates the MVC pattern.

Topics

  • application:didFinishLaunchingWithOptions:

  • Sizing images

    You want to size your images to the placeholder you setup in the application. Having iPhone or iPad do the resizing can drain battery faster.

  • didRecieveMemoryWarning

  • viewDidUnload

Version tag is v1.0

Chapter 5 Table Views

Tables: style property defines one of two types

  • plain Cells with optional header
  • grouped Cells indented with rounded ends caps on top level cells.

There is a nice quick section on how cells are reused to keep memory usage down. Here is a gist that shows the basic pattern. There is an identifier, Cell, that is added to each UITableViewCell created. Once a cell rolls off the screen it becomes available for reuse.

Gist

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] 
               initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    if (cell == nil) {
        cell = [[UITableViewCell alloc] 
               initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    cell.textLabel.text = [[self.dataSource recipeAtIndex:indexPath.row] title];
    return cell;
}

Datasource added to application mainly to extend application so we could delete items from the table. The app started with an immutable array holding recipes. The datasource did more than allowing delete. It provided a clean separation between the model and the controller. The datasource takes care of things like initializing the data and answers questions the table controller needs to know like the number of items.

Version tag is v2.0

Git Lesson

Version tags where not showing up on github. I had to use

git push --tags

to get the tags to show up.

Style and Convention

The accepted style now is to add an underscore to the ivar name in the @synthesize statement. The was confirmed by the authors of the book and they site that even in Apple's templates you will see this convention followed. In the book they slack off so I asked the question.

Gist

@synthesize recipes = _recipes;	 

- (NSArray *)recipes {
    if(nil == _recipes) {
     // create the recipes
    }
    return _recipes;
}

Resources

Qh QuickHubApp is a great menu bar app for my Mac and just $1.99 at the App Store. It helps you to quickly access to GitHub directly from your status bar: Repositories, issues, gists, pull requests, users, organizations and watched repos are just one click away. QuickHub also provides Gists creation feature and will notify you when something changes on your GitHub artifacts.

recipes's People

Contributors

perfectionist avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.