Basic Core Data model versioning

When you add new properties, entities, relationships to an existing data model which is already deployed in production, this will fail with this error: Therewith this does not happen, some steps are necessary. At first, you need to configure Core Data, that data is migrated automatically: The second step is, to create a new version […]

Writing an email client

I was wondering if it could be that hard writing an email client by myself. I thought the basic things couldn’t be that hard, and I was right. I created a new application using the MailCore2 library and fetching mails becomes very easy. Yup, only fetching mails works at the moment. I spend some time […]

Load specific items from NSManagedObjectContext

Given the case you do not want to load all elements from the context but only those matching a certain criteria. For this, you need to use a NSPredicate. NSPredicate *readArticlesPredicate = [NSPredicate predicateWithFormat:@“read == 1″]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; [fetchRequest setEntity: [NSEntityDescription entityForName:@“FeedEntry“ inManagedObjectContext: self.managedObjectContext]]; [fetchRequest setPredicate:readArticlesPredicate]; NSError *error = nil; NSArray […]

Load things from NSManagedObjectContext

How do I load things from NSManagedObjectContext? Not that hard:     NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];     [fetchAccounts setEntity: [NSEntityDescription entityForName:@“YourEntity“ inManagedObjectContext: self.managedObjectContext]];     NSError *error = nil;     NSArray *results = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];     if (error) {         NSLog(@“Error: %@\n%@“, [error localizedDescription], [error userInfo]);         return nil;     }

Inserting things into NSManagedObjectContext

Insert a new item into NSManagedObjectContext: //Creates new NSManagedObject NSManagedObject * obj = [NSEntityDescription insertNewObjectForEntityForName:@“Item“ inManagedObjectContext: self.managedObjectContext]; //Set value(s) [obj setValue: @“yadda yadda“ forKey: @“text“]; //save stuff [[self managedObjectContext] save: nil];  

Browsing through the code base

When I worked as Windows developer, my main tool of choice was obviously Visual Studio. Now I use vim and at first there was a problem: Browsing through code base. How can I browse through my code base? In Visual Studio I just needed to click on an identifier to see the file or class […]