Skip to content

Commit

Permalink
Nullability attributes for Objective-C machine templates
Browse files Browse the repository at this point in the history
  • Loading branch information
justin committed Mar 3, 2016
1 parent 83f031d commit b12d7a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion templates/human.h.motemplate
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "_<$managedObjectClassName$>.h"

@interface <$managedObjectClassName$> : _<$managedObjectClassName$> {}
@interface <$managedObjectClassName$> : _<$managedObjectClassName$>
// Custom logic goes here.
@end
18 changes: 11 additions & 7 deletions templates/machine.h.motemplate
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "<$additionalHeaderFileName$>"
<$endif$>

NS_ASSUME_NONNULL_BEGIN
<$if noninheritedAttributes.@count > 0$>
@interface <$managedObjectClassName$>Attributes: NSObject <$foreach Attribute noninheritedAttributes do$>
+ (NSString *)<$Attribute.name$>;<$endforeach do$>
Expand Down Expand Up @@ -53,11 +54,12 @@
* <$userInfo.discussion$>
*/
<$endif$>

@interface _<$managedObjectClassName$> : <$customSuperentity$>
+ (instancetype)insertInManagedObjectContext:(NSManagedObjectContext *)moc_;
+ (NSString*)entityName;
+ (NSEntityDescription*)entityInManagedObjectContext:(NSManagedObjectContext*)moc_;
@property (nonatomic, readonly, strong) <$managedObjectClassName$>ID* objectID;
@property (nonatomic, readonly, strong) <$managedObjectClassName$>ID*objectID;

<$foreach Attribute noninheritedAttributes do$>
<$if Attribute.userInfo.documentation$>
Expand All @@ -69,9 +71,9 @@
<$endif$>
<$if Attribute.hasDefinedAttributeType$>
<$if Attribute.isReadonly$>
@property (nonatomic, strong, readonly) <$Attribute.objectAttributeType$> <$Attribute.name$>;
@property (nonatomic, strong, readonly<$if Attribute.optional$>, nullable<$endif$>) <$Attribute.objectAttributeType$> <$Attribute.name$>;
<$else$>
@property (nonatomic, strong) <$Attribute.objectAttributeType$> <$Attribute.name$>;
@property (nonatomic, strong<$if Attribute.optional$>, nullable<$endif$>) <$Attribute.objectAttributeType$> <$Attribute.name$>;
<$endif$>
<$if Attribute.hasScalarAttributeType$>
<$if Attribute.isReadonly$>
Expand All @@ -95,10 +97,10 @@
*/
<$endif$>
<$if Relationship.isToMany$>
@property (nonatomic, strong) <$Relationship.immutableCollectionClassName$> *<$Relationship.name$>;
- (<$Relationship.mutableCollectionClassName$>*)<$Relationship.name$>Set;
@property (nonatomic, strong<$if Relationship.optional$>, nullable<$endif$>) <$Relationship.immutableCollectionClassName$> *<$Relationship.name$>;
- (<$if Relationship.optional$>nullable <$endif$><$Relationship.mutableCollectionClassName$>*)<$Relationship.name$>Set;
<$else$>
@property (nonatomic, strong) <$Relationship.destinationEntity.managedObjectClassName$> *<$Relationship.name$>;
@property (nonatomic, strong<$if Relationship.optional$>, nullable<$endif$>) <$Relationship.destinationEntity.managedObjectClassName$> *<$Relationship.name$>;
//- (BOOL)validate<$Relationship.name.initialCapitalString$>:(id*)value_ error:(NSError**)error_;
<$endif$>
<$endforeach do$>
Expand All @@ -119,7 +121,7 @@
* <$FetchedProperty.userInfo.discussion$>
*/
<$endif$>
@property (nonatomic, readonly) NSArray *<$FetchedProperty.name$>;
@property (nonatomic, readonly<$if FetchedProperty.optional$>, nullable<$endif$>) NSArray *<$FetchedProperty.name$>;
<$endforeach do$>
<$if TemplateVar.frc$>
#if TARGET_OS_IPHONE
Expand All @@ -132,6 +134,7 @@
<$endif$>
@end


<$foreach Relationship noninheritedRelationships do$>
<$if Relationship.isToMany$>
@interface _<$managedObjectClassName$> (<$Relationship.name.initialCapitalString$>CoreDataGeneratedAccessors)
Expand Down Expand Up @@ -172,3 +175,4 @@
<$endif$>
<$endforeach do$>
@end
NS_ASSUME_NONNULL_END

0 comments on commit b12d7a4

Please sign in to comment.