*   >> Lese Utdanning Artikler >> science >> programming

iPhone kjernedata Tutorial Part 1

loc] initWithStyle: UITableViewCellStyleValue2 reuseIdentifier: CellIdentifier] autorelease];

}

switch (indexPath.row) {

case 0:

cell.textLabel.text = @ "Name";

cell.detailTextLabel.text = recipes.recipeName;

break;

case 1:

cell.textLabel.text = @ "Cooking Time";

cell.detailTextLabel.text = recipes.

cookingTime;

bryte;

standard:

break;

}

retur celle;

}

- (void) dealloc { Der det står

[oppskrifter utgivelsen];

[super dealloc];

}

end

Lagre begge filene og åpne RootViewController.h og skriv inn følgende kode:

interface RootViewController: UITableViewController {

NSFetchedResultsController * fetchedResultsController;

NSManagedObjectContext * managedObjectContext;

}

property (nonatomic, beholde) NSFetchedResultsController * fetchedResultsController;

property (nonatomic, beholde) NSManagedObjectContext * managedObjectContext;

end

I RootViewController.

m skriver dette i:

#import "RootViewController.h"

#import "AddRecipeViewController.h"

#import "Recipes.h" Anmeldelser

#import "RecipeDetailViewController.h"

implementation RootViewController

synthesize fetchedResultsController, managedObjectContext;

#pragma mark -

#pragma mark Vis livssyklus

- (void) viewDidLoad {

[super viewDidLoad];

self.title = @ "oppskrifter";

self.navigationItem. leftBarButtonItem = self.

editButtonItem;

UIBarButtonItem * addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemAdd mål: selv handling:selector (addRecipe)];

self.navigationItem.rightBarButtonItem = addButton;

[addButton utgivelsen];

NSError * error = null;

if ([performFetch [selv fetchedResultsController]: & error;]!) {

NSLog (@ "Uløste feil% @,% @", feil, [error Userinfo]);

abortere ();

}

}

- (void) viewWillAppear: (BOOL) animert {

[super viewWillAppear: animerte];

[self.

tableView reloadData];

}

#pragma mark -

#pragma mark Legg et nytt objekt

- (void) addRecipe {

AddRecipeViewController * addRecipeView = [[AddRecipeViewController alloc] initWithNibName: @ "AddRecipeViewController "bundle: [NSBundle mainBundle]

Page   <<  [1] [2] [3] [4] [5] [6] [7] >>
Copyright © 2008 - 2016 Lese Utdanning Artikler,https://utdanning.nmjjxx.com All rights reserved.