Tutorial on programming ERP for iPhone with the new @sensiblecocoa database framework 3.0

The new unfinished user guide, provided as a PDF, is a good place to start. I followed Section 3 to set up the project.

I did made some errors; for instance I didn’t choose the Universal option when creating the project. And worse, I copied some invisible strange characters from the PDF into the source, and it ruined all.

But after a couple of days, and an hour a day, an empty project according to Section 3. was running.

Doing the first tests in Section 4. was also easy. So I decided to jump to Exploring Core Data Binding, which is what really interested me.

I did what the user guide told me, and again got an empty app. The guide didn’t mention to change the AppDelegate files, and after studying these I had a path to follow.

Since the PDF is not half completed, I looked at the samples provided. I got some ideas in the upgraded 2.0 samples, but these samples was written for earlier XCode versions.

What helped me, was the new ParseCom App. It was written in a new XCode version. So I used it’s AppDelegate files to rewrite my own project. And after some bug-fixing, it finally ran. And ran very nice indeed!

I make a receipt for you want to try it out here:

  1. Setup your project as explained in Section 3. in the PDF provided
  2. Do as told in the Section 4. “Exploring Core Data Binding”. Remember to check for Core Data.
  3. Change the AppDelegate.h to the following:

#import <UIKit/UIKit.h>

//Added line
@class ViewController;

@interface AppDelegate : UIResponder`

@property (strong, nonatomic) UIWindow *window;

//Added line
@property (strong, nonatomic) ViewController *viewController;

@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;

- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;

@end>

  1. And the top of the AppDelegate.m as follows:

#import "AppDelegate.h"
#import "ViewController.h"
#import "iPadDetailViewController.h"

@implementation AppDelegate

@synthesize window = _window;

@synthesize viewController = _viewController;

@synthesize managedObjectContext = __managedObjectContext;
@synthesize managedObjectModel = __managedObjectModel;
@synthesize persistentStoreCoordinator = __persistentStoreCoordinator;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithStyle:UITableViewStyleGrouped];
UIViewController *rootViewController;
rootViewController = [[UINavigationController alloc]initWithRootViewController:self.viewController];`

self.window.rootViewController = rootViewController;

[self.window makeKeyAndVisible];
return YES;
}

Run it on the iPhone simulator and you should have a great template to do ERP database programming on our lovely Apple mobile devices!

2 replies on “Tutorial on programming ERP for iPhone with the new @sensiblecocoa database framework 3.0”

  1. Thank you so much Mortjac for the tutorial!

    It seems that you’ve missed clicking the “Use Core Data” option in the project creation wizard, which is why you later needed to modify the AppDelegate file. This is mentioned in STV’s book on page 23, 2nd paragraph:

    “Since we’ll be using Core Data, you should be checking the ‘Use Core Data’ option in step number 3.”

    Good luck! 🙂

  2. In fact I did click for “Use Core Data” as told in point 2. The AppDelegate.m lacked references to the controllers and were therefore white.

Comments are closed.