Skip to content

Commit

Permalink
Merge pull request #370 from protocool/feature/xcode9-new-attribute-t…
Browse files Browse the repository at this point in the history
…ypes

Add support for URI and UUID attribute types. Thanks!
  • Loading branch information
atomicbird authored Jul 21, 2018
2 parents db41d58 + b100abe commit cc1304a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode8
osx_image: xcode9
#xcode_project: mogenerator.xcodeproj
#xcode_scheme: mogenerator
script: cd test && rake
21 changes: 20 additions & 1 deletion mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -558,15 +558,34 @@ - (NSString*)objectAttributeClassName {
result = gSwift ? @"AnyObject" : @"NSObject";
}
} else {
result = [self attributeValueClassName];
// Forcibly generate the correct class name in case we are
// running on macOS < 10.13
switch ([self attributeType]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
case NSURIAttributeType:
result = @"NSURL";
break;
case NSUUIDAttributeType:
result = @"NSUUID";
break;
#pragma clang diagnostic pop
default:
result = [self attributeValueClassName];
}
}

if (gSwift) {
if ([result isEqualToString:@"NSString"]) {
result = @"String";
} else if ([result isEqualToString:@"NSDate"]) {
result = @"Date";
} else if ([result isEqualToString:@"NSData"]) {
result = @"Data";
} else if ([result isEqualToString:@"NSURL"]) {
result = @"URL";
} else if ([result isEqualToString:@"NSUUID"]) {
result = @"UUID";
}
}
return result;
Expand Down
5 changes: 5 additions & 0 deletions momcom/NSAttributeDescription+momcom.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ + (void)initialize
@"Float" : @(NSFloatAttributeType),
@"String" : @(NSStringAttributeType),
@"Transformable" : @(NSTransformableAttributeType),
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
@"URI" : @(NSURIAttributeType),
@"UUID" : @(NSUUIDAttributeType),
#pragma clang diagnostic pop
};
});
}
Expand Down
2 changes: 1 addition & 1 deletion test/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ end
#==============================
# Variables
#==============================
OSX_SDK="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk"
OSX_SDK="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk"
OSX_VERSION="10.10"
LINKED_FRAMEWORKS="-framework Foundation -framework AppKit -framework CoreData"

Expand Down

0 comments on commit cc1304a

Please sign in to comment.