From e608eb60d671a736511b9c92531952eb02fab062 Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Sat, 2 May 2015 13:53:20 +0300 Subject: [PATCH] [add] NSCopying protocol support to TNCheckBoxData class and subclasses --- src/TNCheckBoxData.h | 2 +- src/TNCheckBoxData.m | 26 ++++++++++++++++++++++++++ src/TNCircularCheckBoxData.m | 16 ++++++++++++++++ src/TNFillCheckBoxData.m | 13 +++++++++++++ src/TNImageCheckBoxData.m | 13 +++++++++++++ src/TNRectangularCheckBoxData.m | 18 ++++++++++++++++++ 6 files changed, 87 insertions(+), 1 deletion(-) diff --git a/src/TNCheckBoxData.h b/src/TNCheckBoxData.h index 20f60e8..f96d1fc 100644 --- a/src/TNCheckBoxData.h +++ b/src/TNCheckBoxData.h @@ -8,7 +8,7 @@ #import -@interface TNCheckBoxData : NSObject +@interface TNCheckBoxData : NSObject @property (nonatomic, copy) NSString *identifier; @property (nonatomic) NSInteger tag; diff --git a/src/TNCheckBoxData.m b/src/TNCheckBoxData.m index 92e81f5..d2748bb 100644 --- a/src/TNCheckBoxData.m +++ b/src/TNCheckBoxData.m @@ -10,6 +10,32 @@ @implementation TNCheckBoxData +#pragma mark - Copying +- (id)copyWithZone:(NSZone *)zone +{ + TNCheckBoxData *copy = [[[self class] allocWithZone:zone] init]; + + if (copy) { + copy.identifier = self.identifier; + copy.tag = self.tag; + copy.checked = self.checked; + + copy.labelText = self.labelText; + copy.labelFont = self.labelFont; + copy.labelColor = self.labelColor; + + copy.labelMarginLeft = self.labelMarginLeft; + copy.labelWidth = self.labelWidth; + copy.labelHeight = self.labelHeight; + + copy.labelBorderWidth = self.labelBorderWidth; + copy.labelBorderCornerRadius = self.labelBorderCornerRadius; + copy.labelBorderColor = self.labelBorderColor; + } + + return copy; +} + #pragma mark - Debug - (NSString *)description { return [NSString stringWithFormat:@"[TNCheckBoxData] Identifier: %@ - Tag: %i - Checked: %d", self.identifier, self.tag, self.checked]; diff --git a/src/TNCircularCheckBoxData.m b/src/TNCircularCheckBoxData.m index a629ea7..e99c255 100644 --- a/src/TNCircularCheckBoxData.m +++ b/src/TNCircularCheckBoxData.m @@ -10,6 +10,22 @@ @implementation TNCircularCheckBoxData +#pragma mark - Copying +- (id)copyWithZone:(NSZone *)zone +{ + TNCircularCheckBoxData *copy = [super copyWithZone:zone]; + + if (copy) { + copy.borderColor = self.borderColor; + copy.circleColor = self.circleColor; + + copy.borderRadius = self.borderRadius; + copy.circleRadius = self.circleRadius; + } + + return copy; +} + #pragma mark - Getters and setters - (UIColor *)borderColor { diff --git a/src/TNFillCheckBoxData.m b/src/TNFillCheckBoxData.m index e0c8e49..3553379 100644 --- a/src/TNFillCheckBoxData.m +++ b/src/TNFillCheckBoxData.m @@ -10,4 +10,17 @@ @implementation TNFillCheckBoxData +#pragma mark - Copying +- (id)copyWithZone:(NSZone *)zone +{ + TNFillCheckBoxData *copy = [super copyWithZone:zone]; + + if (copy) { + copy.labelBgNormalColor = self.labelBgNormalColor; + copy.labelBgSelectedColor = self.labelBgSelectedColor; + } + + return copy; +} + @end diff --git a/src/TNImageCheckBoxData.m b/src/TNImageCheckBoxData.m index 3604e54..146509e 100644 --- a/src/TNImageCheckBoxData.m +++ b/src/TNImageCheckBoxData.m @@ -10,4 +10,17 @@ @implementation TNImageCheckBoxData +#pragma mark - Copying +- (id)copyWithZone:(NSZone *)zone +{ + TNImageCheckBoxData *copy = [super copyWithZone:zone]; + + if (copy) { + copy.checkedImage = self.checkedImage; + copy.uncheckedImage = self.uncheckedImage; + } + + return copy; +} + @end diff --git a/src/TNRectangularCheckBoxData.m b/src/TNRectangularCheckBoxData.m index edbb351..7bbb9e4 100644 --- a/src/TNRectangularCheckBoxData.m +++ b/src/TNRectangularCheckBoxData.m @@ -10,6 +10,24 @@ @implementation TNRectangularCheckBoxData +#pragma mark - Copying +- (id)copyWithZone:(NSZone *)zone +{ + TNRectangularCheckBoxData *copy = [super copyWithZone:zone]; + + if (copy) { + copy.borderColor = self.borderColor; + copy.rectangleColor = self.rectangleColor; + + copy.borderWidth = self.borderWidth; + copy.borderHeight = self.borderHeight; + copy.rectangleWidth = self.rectangleWidth; + copy.rectangleHeight = self.rectangleHeight; + } + + return copy; +} + #pragma mark - Getters and setters - (UIColor *)borderColor {