Skip to content

Commit

Permalink
Added support for xcdatamodeld bundle (current version will be chosen…
Browse files Browse the repository at this point in the history
… automatically)
  • Loading branch information
Alexander Zats committed Apr 13, 2012
1 parent b08eede commit 536bc0f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,21 @@ - (void)setModel:(NSString*)path;
{
assert(!model); // Currently we only can load one model.

// We will try to detect a bundle, not sure about compatabilty with the older Xcode versions
BOOL isDirectory = NO;
// it's a directory, let's try to find a ".xccurrentversion" file so we can locate current version of the model
if ([[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDirectory] && isDirectory) {
// in 4.x version of Xcode there is a .xccurrentversion plist with _XCCurrentVersionName key pointing to the current model
NSString *xccurrentversionPath = [path stringByAppendingPathComponent:@".xccurrentversion"];
if ([[NSFileManager defaultManager] fileExistsAtPath:xccurrentversionPath]) {
NSDictionary *xccurrentversionPlist = [NSDictionary dictionaryWithContentsOfFile:xccurrentversionPath];
NSString *currentModelName = [xccurrentversionPlist valueForKey:@"_XCCurrentVersionName"];
if (currentModelName) {
path = [path stringByAppendingPathComponent:currentModelName];
}
}
}

origModelBasePath = [path stringByDeletingLastPathComponent];

if( ![[NSFileManager defaultManager] fileExistsAtPath:path]){
Expand Down

0 comments on commit 536bc0f

Please sign in to comment.