Skip to content

Commit

Permalink
Merge pull request #138 from sagran/master
Browse files Browse the repository at this point in the history
[FIX] Handle .xcdatamodeld bundles that are missing an .xccurrentversion but contain a single .xcdatamodel file. (Sixten Otto, Sergey Grankin)
  • Loading branch information
rentzsch committed Nov 20, 2012
2 parents 82b097d + a3e914b commit ce9cae1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,16 @@ - (void)setModel:(NSString*)momOrXCDataModelFilePath {
momOrXCDataModelFilePath = [momOrXCDataModelFilePath stringByAppendingPathComponent:currentModelName];
}
}
else {
// Freshly created models with only one version do NOT have a .xccurrentversion file, but only have one model
// in them. Use that model.
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self endswith %@", @".xcdatamodel"];
NSArray *contents = [[fm contentsOfDirectoryAtPath:momOrXCDataModelFilePath error:nil]
filteredArrayUsingPredicate:predicate];
if (contents.count == 1) {
momOrXCDataModelFilePath = [momOrXCDataModelFilePath stringByAppendingPathComponent:[contents lastObject]];
}
}
}

NSString *momFilePath = nil;
Expand Down

0 comments on commit ce9cae1

Please sign in to comment.