Search Results

Search found 4 results on 1 pages for 'iphonecoredatarecipes'.

Page 1/1 | 1 

  • I am getting the error Wrong type argument to unary minus and Expected ';' before ':' token

    - by James B.
    I am getting the error Wrong type argument to unary minus and Expected ';' before ':' token The error occurs at the - (NSIndexPath *).... line I am really New at this, so if there is anymore info needed, please ask, if you need to see the entire app, please e-mail me @ james at sevenotwo dot com. the app isn't really complicated. it is based on the sample code on Apple's website for the iphonedatacorerecipes code. #pragma mark - #pragma mark Editing rows - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSIndexPath *rowToSelect = indexPath; NSInteger section = indexPath.section; BOOL isEditing = self.editing; // If editing, don't allow notes to be selected // Not editing: Only allow notes to be selected if ((isEditing && section == NOTES_SECTION) || (!isEditing && section != NOTES_SECTION)) { [tableView deselectRowAtIndexPath:indexPath animated:YES]; rowToSelect = nil; } return rowToSelect; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger section = indexPath.section; UIViewController *nextViewController = nil; /* What to do on selection depends on what section the row is in. For Type, Notes, and Instruments, create and push a new view controller of the type appropriate for the next screen. */ switch (section) { case TYPE_SECTION: nextViewController = [[TypeSelectionViewController alloc] initWithStyle:UITableViewStyleGrouped]; ((TypeSelectionViewController *)nextViewController).doctor = doctor; break; case NOTES_SECTION: nextViewController = [[NotesViewController alloc] initWithNibName:@"NotesView" bundle:nil]; ((NotesViewController *)nextViewController).doctor = doctor; break; case INSTRUMENTS_SECTION: nextViewController = [[InstrumentDetailViewController alloc] initWithStyle:UITableViewStyleGrouped]; ((InstrumentDetailViewController *)nextViewController).doctor = doctor; if (indexPath.row < [doctor.instruments count]) { Instrument *instrument = [instruments objectAtIndex:indexPath.row]; ((InstrumentDetailViewController *)nextViewController).instrument = instrument; } break; default: break; } // If we got a new view controller, push it . if (nextViewController) { [self.navigationController pushViewController:nextViewController animated:YES]; [nextViewController release]; } } - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCellEditingStyle style = UITableViewCellEditingStyleNone; // Only allow editing in the instruments section. // In the instruments section, the last row (row number equal to the count of instruments) is added automatically (see tableView:cellForRowAtIndexPath:) to provide an insertion cell, so configure that cell for insertion; the other cells are configured for deletion. if (indexPath.section == INSTRUMENTS_SECTION) { // If this is the last item, it's the insertion row. if (indexPath.row == [doctor.instruments count]) { style = UITableViewCellEditingStyleInsert; } else { style = UITableViewCellEditingStyleDelete; } } return style; } - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { // Only allow deletion, and only in the instruments section if ((editingStyle == UITableViewCellEditingStyleDelete) && (indexPath.section == INSTRUMENTS_SECTION)) { // Remove the corresponding instrument object from the doctor's instrument list and delete the appropriate table view cell. Instrument *instrument = [instruments objectAtIndex:indexPath.row]; [doctor removeInstrumentsObject:instrument]; [instruments removeObject:instrument]; NSManagedObjectContext *context = instrument.managedObjectContext; [context deleteObject:instrument]; [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationTop]; } }

    Read the article

  • NSPredicates with custom objects

    - by Horatiu Paraschiv
    Hi, I have the following problem and I cannot figure out how to solve it. I have an NSSet which contains Person objects (NSDictionary with 2 keys: name, age). From time to time I get an NSArray of Person objects and I want to add them to my NSSet but I want to filter out the duplicates. I'm thinking I could use NSPredicates but I am reading the documentation and I can't understand how should I format my NSPredicate to filter out my array content based on what I already have in NSSet. So I have an NSSet with 5 custom objects and I get an NSArray with 6 objects but 3 of them already exist in NSSet and I want to filter them out. I understand what I should do with basic objects like Strings, integers, etc but I don't know how to extend this to work with custom more complex objects. I hope I was clear enough with my problem. Any starting point, example or advice is much appreciated. Thank you!

    Read the article

  • iPhone Core Data does not refresh table

    - by Brian515
    Hi all, I'm trying to write an application with Core Data, and I have been able to successfully read and write to the core data database. However, if I write to the database in one view controller, my other view controllers will not see the change until the app is closed then reopened again. This is really frustrating. I'm not entirely sure how to get the refresh - (void)refreshObject:(NSManagedObject *)object mergeChanges:(BOOL)flag method to work. How do I get a reference to my managed object? Anyways, here's the code I'm using to read the data back. This is in the viewDidLoad method. NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Website" inManagedObjectContext:managedObjectContext]; [request setEntity:entity]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"siteName" ascending:NO]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [request setSortDescriptors:sortDescriptors]; [sortDescriptor release]; [sortDescriptors release]; NSError *error = nil; NSMutableArray *mutableFetchResults = [[managedObjectContext executeFetchRequest:request error:&error] mutableCopy]; if(mutableFetchResults == nil) { //Handle the error } [self setNewsTitlesArray:mutableFetchResults]; [mutableFetchResults release]; [request release]; [newsSourcesTableView reloadData]; Thanks for help in advance!

    Read the article

1