Core Data Error: Can’t Find Model for Source Store
Posted July 29, 2009 by ablogontechCategories: Uncategorized
Tags: Can't find model for source store, Core Data, iPhone OS 3.0, SQLite
Well, I’m still learning how Core Data works and how it works with iPhone OS 3.0. The following displays how I was able to resolve an error running an app using Core Data and a pre-populated SQLite database. The error gives the reason as “Can’t find model for source store”.
1. Create a new SQLite database with the following tables and columns.
|
Table |
Column |
| ZFriends | |
| FirstName | |
| LastName | |
| Z_METADATA | |
| Z_VERSION (Int Primary Key) | |
| Z_UUID (VARCHAR(255)) | |
| Z_PLIST (BLOB) | |
| Z_PRIMARYKEY | |
| Z_ENT (Int Primary Key) | |
| Z_NAME (VARCHAR) | |
| Z_SUPER (INTEGER) | |
| Z_MAX (INTEGER) |
ZFriends is an example of the pre-populated table with the columns (or attributes) FirstName and LastName. Z_METADATA and Z_PRIMARYKEY are the tables necessary for Core Data functionality.
2. Create the Data Model (xcdatamodel file) in XCode.
a. Create the Entity (Table Name without the leading ’Z’).
b. Create the attributes (Columns).
Using a Pre-Populated SQLite Database with Core Data on iPhone OS 3.0
Posted July 13, 2009 by ablogontechCategories: Uncategorized
Tags: Core Data, Dev, iPhone, iPhone OS 3.0, Pre-Populated, SQLite
I was recently re-writing a yet to be published iPhone app to use Core Data with a pre-populated SQLite database. I was able to get the app to function with a new database using the CoreDataBooks sample code as a reference but could not get the app to read a pre-populated database added to the project.
After many hours of troubleshooting, I discovered differences in the pre-populated database and a Core Data created SQLite database. The pre-populated database consisted of just my simple 1 table structure and the Core Data created SQLite database consisted of “extra ‘Z’ tables’ For example: Z_METADATA, I searched the Internet and Apple docs but could not find a utility or any other way to convert or prep a pre-populated SQLite database for use with Core Data.
Right or wrong. Here’s what I finally did (NOTE: All the ‘coding’ is based on the CoreDataBooks sampe):
In XCode:
1. Ensure the CoreData framework is added to your project.
** If creating a new project, check the ‘Use Core Data for storage’ option when selecting a template.
2. Create the Data Model file (xcdatamodel) if not already created.
a. Click File | New File.
b. Choose iPhone OS | Resource | Data Model
c. Click Next, name the file and click Next again.
d. If the model class is already created, select it from the next window. You can create it later if it isn’t created already.
2. Add an Entity (table name) and bind it to the class.
a. Click Design | Data Model | Add Entity
b. Rename Entity to the table name you wish to create and change the Class to the desired class name.
3. Create the Attributes (columns).
a. Click Design | Data Model | Add Attribute
b. Rename newAttribute to the desired column name and set the type.
c. Repeat step b for each additional attribute.
4. Set the name of the SQLite database name and location in the AppDelegate.m file (Please refer to the CoreDataBooks sample code for further info).
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
if (persistentStoreCoordinator != nil) {
return persistentStoreCoordinator;
}
NSString *storePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @”CoreData.sqlite”];
/*
Set up the store.
For the sake of illustration, provide a pre-populated default store.
*/
NSFileManager *fileManager = [NSFileManager defaultManager];
// If the expected store doesn’t exist, copy the default store.
if (![fileManager fileExistsAtPath:storePath]) {
NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:@”CoreData” ofType:@”sqlite”];
if (defaultStorePath) {
[fileManager copyItemAtPath:defaultStorePath toPath:storePath error:NULL];
}
}NSURL *storeUrl = [NSURL fileURLWithPath:storePath];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]];NSError *error;
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) {
// Update to handle the error appropriately.
NSLog(@”Unresolved error %@, %@”, error, [error userInfo]);
exit(-1); // Fail
}
return persistentStoreCoordinator;
}5. Build and Run the app.
In Finder:
1. Use Spotlight to search for the SQLite database created by the app in the iPhone Simulator. This is /Users/<Username>/Library/Application Support/iPhone Simulator/User/Application/<Application GUID>/Documents/<database name.sqlite>
2. Copy that database to a working folder.
3. Populate that database.
4. Add the populated database to the project.
I hope this helps! If anyone has a better or preferred way of formatting a SQLite database for use with Core Data, please let me know.
WatchGuard x550e: Upgrade from a WatchGuard x500
Posted July 6, 2009 by ablogontechCategories: Uncategorized
Tags: Firebox, Policy Manager, WatchGuard, x550e
With WatchGuard dropping the support on the WatchGuard x500 Firebox product in September 2009 you may find yourself configuring a new WatchGuard. We recently purchased a WatchGuard Firebox Core x550e. There is good news and bad new.
The bad news: You cannot use the config backup file from the x500 to configure the x550e.
The good news: After you run the setup wizard to configure the x550e Firebox, you can configure the firewall policy with a backup (XML file) from the x550. Here’s the steps:
1.On the x500 Policy Manager, click File | Backup and save the backup to an XML file.
2. On the x550e Policy Manager, click File | Restore and load the XML from step 1.
3. On the x550e Policy Manager, click Network | Configuration and click Yes to the message concerning whether you want to change from a 6 interface Firebox to a 4 interface Firebox. If you don’t do this, you will receive a DATA_ERROR concerning the interfaces when attempting to save the the firebox in the next step.
4. On the x550e Policy Manager, click File | Save > To Firebox.
5. You should know have the policies from the x500 on the new x550e Firebox.
WatchGuard Firebox x550e Factory Default
Posted July 6, 2009 by ablogontechCategories: Uncategorized
Tags: Factory Default, Firebox, WatchGuard, x550
I recently found myself with the need to set a WatchGuard Firebox x550e to the factory default. If you’ve ever had to do this for any WatchGuard Firebox product you know there are different procedures depending upon which Firebox you have. This WatchGuard support article details how to do a factory default of a Firebox X Core or Peak e-Series and non e-Series.
XenServer 5.0: Creating a Windows File Share
Posted June 9, 2009 by ablogontechCategories: Uncategorized
Tags: Boot from ISO, CIFS, ISO, Windows Share, XenCenter, XenServer
At some point you might need to setup a VM using an ISO file. This post shows how to setup a file share for use by XenServer.
1. Within XenServer, click Storage | New Storage Repository.
2. Click the Windows File Sharing (CIFS) radio button and click next.
3. Enter the desired name and share name. Click Finish.
4. The new repository (CIFS ISO library) is displayed in the left-hand pane of XenCenter with details on the right-hand-side.
5. Now you can use the ISOs on this Windows Share to setup your VM by changing the DVD drive setting to the desired ISO.
SQL: Truncating a SQL Database Log
Posted June 9, 2009 by ablogontechCategories: Uncategorized
Tags: ldf, Logs, SQL, Truncate
Thanks to John McBride for helping me with this.
1. In SQL Management Studio, make sure you are connected to ‘master’ in the available databases drop-down box.
2. Click ‘New Query’ to open a query window.
3. Get the logfile name by:
a. Right-click the database
b. Select Properties
c. Click Files
d. Note the name of the log file.
4. Type the following in the query window:
Use <YOUR_DB_NAME>
Go
backup log <YOUR_DB_NAME> with truncate_only
go
dbcc shrinkfile(<YOUR_DB_LOGFILE_NAME,1)
go5. Click the Execute button.
Citrix XenCenter Install and Configuration
Posted May 26, 2009 by ablogontechCategories: Uncategorized
Tags: Citrix, Install, XenCenter, XenServer
The screen captures in this post outline the installation and basic configuration of Citrix XenCenter on Windows Vista. XenCenter is the GUI management utility for XenServer. XenCenter can be downloaded from Citrix’s website.
Launch the installation file you downloaded from Citrix’s website.
Click Next and select whether you need XenServer 4.0 Support. We did not need XenServer 4.0 support for this installation.
Click Next and accept the default installation folder.
Click Install to begin the installation.
It is as simple as that! Click Finish to complete the installation.
Double-click the Desktop icon to start XenCenter.
The splash screen will appear.
Tell XenCenter whether you’d like it to check for updates (We clicked Yes).
The XenCenter GUI will now display.
Click the ‘Add your XenServer’ icon to add your server to the list.
On the Add New Server window add the hostname, username and password.
Click Connect to connect and synchronize with your server.
Now you must activate your XenServer. Click the checkbox next to the server and click Activate.
Activating the XenServer will send you to the activation website where you must fill out the form in order to receive a new license.
You will receive a license file (license.xslic). From the XenCenter console, go to Server | Install License Key and navigate to the license.xslic file. Once the license is applied, it is displayed in the General tab of the server.
Citrix XenServer 5.0.0 Free Version: A Basic Install
Posted May 26, 2009 by ablogontechCategories: Uncategorized
Tags: Citrix, XenServer
Well, I’m a little late to the game but I guess better late than never. This post covers the basic installation of Citrix’s XenServer 5.0.0 Free Version. I apologize for the less than stellar screen captures. I had an old CRT connected to the server I used for the install. L I promise the next post covering the XenCenter Installation and Configuration will be MUCH nicer!
Prerequistes
If you don’t like reading the documentation before installing a product, the best piece of advice I can give is to ensure your server is capable of virtualization technology and it is enabled in the BIOS. I used an HP\Compaq Proliant DL365 with and AMD processor for this installation and as you can see in the picture below the virtualization option is buried under the Processor options.
If your server is not compatible with virtualization technology or the option is disabled, you will get the following message when attempting to install XenServer:
Once virtualization is enabled pop in the XenServer CD-ROM and let’s get started! The CD will boot to the Citrix XenServer installation splash screen and automatically boot to the installation program.
At this time you will have the option to install\upgrade XenServer Host, load a driver or convert the existing OS to a VM.
For this post we are installing XenServer from scratch so we’ll select the first option and then select the correct keymap.
WARNING!!! If you continue the install from this point, all data will be lost.
What would an installation be without an End User Licensing Agreement (EULA)?
Next, we’ll select the installation source and whether or not we are going to install the Linux Pack.
Now, we will verify the installation source.
Let’s set a root password we can remember.
We must now configure the NIC, Hostname, DNS and Time settings.
Time Zone
NTP
Confirm and start the installation!
Installation Complete!
Citrix XenServer Splash Screen: ![]()
Citrix XenServer Console:
Checkout the Citrix website to learn more about Citrix XenServer. Come back soon for the next post covering the XenCenter installation and configuration plus better screen captures.
New Citrix Receiver for iPhone
Posted May 5, 2009 by ablogontechCategories: Uncategorized
Tags: Citrix, Citrix Receiver iPhone
The new Citrix Receiver for iPhone is now available via Apple’s App Store. Version 1.0 features Citrix Access Gateway compatiblity and some changes to the settings as shown below. One caveat: There is no upgrade path from version 0.9 to 1.0. It is a separate download from the App Store. However, it isn’t really a big deal. Just down load the new one, delete the old one and login!


If you opt to turn off the Sign In Automatically setting, the Account Settings (Login) screen will appear each time you open the Citrix Receiver for iPhone app.
Thanks to Brian Madden for his tweet that alerted me of the new download!