*   >> Lecture Éducation Articles >> science >> la programmation

iPhone de base de données Tutorial Part 1

Button presse];

NSError * error = nul;

Si ([performFetch [auto] fetchedResultsController: & erreur;]!) {

NSLog (@ "non résolus erreur% @,% @", erreur [Erreur userInfo]);

abort ();

}

}

- (void) viewWillAppear: (BOOL) animée {

[super viewWillAppear: animation];

[self.

tableView reloadData];

}

#pragma mark -

#pragma mark Ajouter un nouvel objet

- (void) {

addRecipe

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

Recettes * = recettes (Recettes *) [NSEntityDescription insertNewObjectForEntityForName: @" "inManagedObjectContext Recettes: self.managedObjectContext];

addRecipeView.

recipes = recettes;

* UINavigationController NavController = [[UINavigationController alloc] initWithRootViewController: addRecipeView];

[self.navigationController presentModalViewController: NavController animé: OUI];

[addRecipeView presse];

}

#pragma mark -

#pragma marque Table View méthodes

- (NSInteger) numberOfSectionsInTableView: (UITableView *) tableView {

< p> Retour [[fetchedResultsController sections] comptent];

}

- (NSInteger) tableView: (UITableView *) tableView numberOfRowsInSection: (NSInteger) section {

id sectionInfo = [[fetchedResultsController sections] objectAtIndex: section];

retour [sectionInfo numberOfObjects];

}

- (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath {

NSString statique * CellIdentifier = @ "Cell";

* UITableViewCell cellule = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];

Si (cellulaire == nil) {

cellule = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: CellIdentifier] autorelease];

}

* NSManagedObject ManagedObject = [fetchedResultsController objectAtIndexPath: indexPath] ;

cell.

textLabel.text = [[ManagedObject valueForKey: @ "recipeName"] Description];

cellule de retour;

}

- ( void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath {

* RecipeDetailViewController recipeDetailView = [[alloc RecipeDetailViewController] initWithStyle: UITableViewStyleGrouped];

Page   <<  [1] [2] [3] [4] [5] [6] [7] >>
Copyright © 2008 - 2016 Lecture Éducation Articles,https://lecture.nmjjxx.com All rights reserved.