Skip to content

Commit

Permalink
Use copy for NSURL and NSDate
Browse files Browse the repository at this point in the history
From @adlai:
This is pretty pedantic, but technically correct and it will improve the world for the 0 developers who created MYMutableDate : NSDate and set that on a builder object.
  • Loading branch information
rahul-malik committed Dec 15, 2017
1 parent 4bdf16d commit 801d97e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
5 changes: 3 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ disabled_rules: # rule identifiers to exclude from running
- todo
- line_length
- cyclomatic_complexity
- file_length
included: # paths to include during linting. `--path` is ignored if present.
- Sources
- Tests
Expand All @@ -13,8 +14,8 @@ line_length: 120

# parameterized rules are first parameterized as a warning level, then error level.
type_body_length:
- 300 # warning
- 400 # error
- 400 # warning
- 500 # error

reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji)

8 changes: 4 additions & 4 deletions Examples/Cocoa/Sources/Objective_C/include/Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ NS_ASSUME_NONNULL_BEGIN
@property (nullable, nonatomic, copy, readonly) NSString * identifier;
@property (nonnull, nonatomic, strong, readonly) Image * image;
@property (nullable, nonatomic, strong, readonly) NSDictionary<NSString *, NSNumber /* Integer */ *> * counts;
@property (nullable, nonatomic, strong, readonly) NSDate * createdAt;
@property (nullable, nonatomic, copy, readonly) NSDate * createdAt;
@property (nullable, nonatomic, strong, readonly) NSSet<User *> * contributors;
@property (nullable, nonatomic, copy, readonly) NSString * descriptionText;
@property (nullable, nonatomic, strong, readonly) NSDictionary<NSString *, NSString *> * creator;
@property (nullable, nonatomic, strong, readonly) NSURL * url;
@property (nullable, nonatomic, copy, readonly) NSURL * url;
+ (NSString *)className;
+ (NSString *)polymorphicTypeIdentifier;
+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dictionary;
Expand All @@ -41,11 +41,11 @@ NS_ASSUME_NONNULL_BEGIN
@property (nullable, nonatomic, copy, readwrite) NSString * identifier;
@property (nonnull, nonatomic, strong, readwrite) Image * image;
@property (nullable, nonatomic, strong, readwrite) NSDictionary<NSString *, NSNumber /* Integer */ *> * counts;
@property (nullable, nonatomic, strong, readwrite) NSDate * createdAt;
@property (nullable, nonatomic, copy, readwrite) NSDate * createdAt;
@property (nullable, nonatomic, strong, readwrite) NSSet<User *> * contributors;
@property (nullable, nonatomic, copy, readwrite) NSString * descriptionText;
@property (nullable, nonatomic, strong, readwrite) NSDictionary<NSString *, NSString *> * creator;
@property (nullable, nonatomic, strong, readwrite) NSURL * url;
@property (nullable, nonatomic, copy, readwrite) NSURL * url;
- (instancetype)initWithModel:(Board *)modelObject;
- (Board *)build;
- (void)mergeWithModel:(Board *)modelObject;
Expand Down
4 changes: 2 additions & 2 deletions Examples/Cocoa/Sources/Objective_C/include/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN

@interface Image : NSObject<NSCopying, NSSecureCoding>
@property (nonatomic, assign, readonly) NSInteger height;
@property (nullable, nonatomic, strong, readonly) NSURL * url;
@property (nullable, nonatomic, copy, readonly) NSURL * url;
@property (nonatomic, assign, readonly) NSInteger width;
+ (NSString *)className;
+ (NSString *)polymorphicTypeIdentifier;
Expand All @@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN

@interface ImageBuilder : NSObject
@property (nonatomic, assign, readwrite) NSInteger height;
@property (nullable, nonatomic, strong, readwrite) NSURL * url;
@property (nullable, nonatomic, copy, readwrite) NSURL * url;
@property (nonatomic, assign, readwrite) NSInteger width;
- (instancetype)initWithModel:(Image *)modelObject;
- (Image *)build;
Expand Down
12 changes: 6 additions & 6 deletions Examples/Cocoa/Sources/Objective_C/include/Pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ NS_ASSUME_NONNULL_BEGIN
@property (nullable, nonatomic, strong, readonly) Board * board;
@property (nullable, nonatomic, strong, readonly) NSDictionary * visualSearchAttrs;
@property (nullable, nonatomic, copy, readonly) NSString * color;
@property (nullable, nonatomic, strong, readonly) NSURL * link;
@property (nullable, nonatomic, copy, readonly) NSURL * link;
@property (nonnull, nonatomic, copy, readonly) NSString * identifier;
@property (nullable, nonatomic, strong, readonly) Image * image;
@property (nonnull, nonatomic, strong, readonly) NSDate * createdAt;
@property (nonnull, nonatomic, copy, readonly) NSDate * createdAt;
@property (nullable, nonatomic, strong, readonly) NSArray<PinAttributionObjects *> * attributionObjects;
@property (nullable, nonatomic, strong, readonly) NSURL * url;
@property (nullable, nonatomic, copy, readonly) NSURL * url;
+ (NSString *)className;
+ (NSString *)polymorphicTypeIdentifier;
+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dictionary;
Expand All @@ -72,12 +72,12 @@ NS_ASSUME_NONNULL_BEGIN
@property (nullable, nonatomic, strong, readwrite) Board * board;
@property (nullable, nonatomic, strong, readwrite) NSDictionary * visualSearchAttrs;
@property (nullable, nonatomic, copy, readwrite) NSString * color;
@property (nullable, nonatomic, strong, readwrite) NSURL * link;
@property (nullable, nonatomic, copy, readwrite) NSURL * link;
@property (nonnull, nonatomic, copy, readwrite) NSString * identifier;
@property (nullable, nonatomic, strong, readwrite) Image * image;
@property (nonnull, nonatomic, strong, readwrite) NSDate * createdAt;
@property (nonnull, nonatomic, copy, readwrite) NSDate * createdAt;
@property (nullable, nonatomic, strong, readwrite) NSArray<PinAttributionObjects *> * attributionObjects;
@property (nullable, nonatomic, strong, readwrite) NSURL * url;
@property (nullable, nonatomic, copy, readwrite) NSURL * url;
- (instancetype)initWithModel:(Pin *)modelObject;
- (Pin *)build;
- (void)mergeWithModel:(Pin *)modelObject;
Expand Down
4 changes: 2 additions & 2 deletions Examples/Cocoa/Sources/Objective_C/include/User.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nullable, nonatomic, copy, readonly) NSString * firstName;
@property (nullable, nonatomic, strong, readonly) Image * image;
@property (nullable, nonatomic, strong, readonly) NSDictionary<NSString *, NSNumber /* Integer */ *> * counts;
@property (nullable, nonatomic, strong, readonly) NSDate * createdAt;
@property (nullable, nonatomic, copy, readonly) NSDate * createdAt;
@property (nullable, nonatomic, copy, readonly) NSString * username;
@property (nullable, nonatomic, copy, readonly) NSString * bio;
+ (NSString *)className;
Expand All @@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nullable, nonatomic, copy, readwrite) NSString * firstName;
@property (nullable, nonatomic, strong, readwrite) Image * image;
@property (nullable, nonatomic, strong, readwrite) NSDictionary<NSString *, NSNumber /* Integer */ *> * counts;
@property (nullable, nonatomic, strong, readwrite) NSDate * createdAt;
@property (nullable, nonatomic, copy, readwrite) NSDate * createdAt;
@property (nullable, nonatomic, copy, readwrite) NSString * username;
@property (nullable, nonatomic, copy, readwrite) NSString * bio;
- (instancetype)initWithModel:(User *)modelObject;
Expand Down
3 changes: 2 additions & 1 deletion Sources/Core/ObjectiveCIR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ extension Schema {

func memoryAssignmentType() -> ObjCMemoryAssignmentType {
switch self {
case .string(format: .none):
// Use copy for any string, date, url etc.
case .string:
return .copy
case .boolean, .float, .integer, .enumT:
return .assign
Expand Down

0 comments on commit 801d97e

Please sign in to comment.