This project is from iOS SDK Programming by Chris Adamson and Bill Dudney. Beta 2.
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
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.
- (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
Version tags where not showing up on github. I had to use
git push --tags
to get the tags to show up.
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.
@synthesize recipes = _recipes;
- (NSArray *)recipes {
if(nil == _recipes) {
// create the recipes
}
return _recipes;
}
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.