Skip to content
This repository has been archived by the owner on Mar 31, 2019. It is now read-only.

Commit

Permalink
Disable -init in some classes to fix Xcode warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
junpluse committed Nov 9, 2016
1 parent e72e1e5 commit 22ff97b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
4 changes: 4 additions & 0 deletions ScreenLayout/SCLLayoutConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface SCLLayoutConstraint : NSObject <NSCopying, NSSecureCoding>

- (instancetype)init NS_UNAVAILABLE;

/**
@abstract Creates a SCLLayoutConstraint instance with the specified items.
@param items An array constaining the SCLLayoutConstraintItem objects.
Expand Down Expand Up @@ -48,6 +50,8 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface SCLLayoutConstraintItem : NSObject <NSCopying, NSSecureCoding>

- (instancetype)init NS_UNAVAILABLE;

/**
@abstract Creates a SCLLayoutConstraintItem instance with the specified screen, anchor point and rotation.
@param screen The screen which the receiver defines the geometry for.
Expand Down
22 changes: 9 additions & 13 deletions ScreenLayout/SCLLayoutConstraint.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,15 @@ - (instancetype)copyWithZone:(NSZone *)zone

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
self = [self init];
NSArray *items = [aDecoder scl_decodeArrayOfObjectsOfClass:[SCLLayoutConstraintItem class] forSelector:@selector(items)];

self = [self initWithItems:items];
if (!self) {
return nil;
}

_uuid = [aDecoder scl_decodeObjectOfClass:[NSUUID class] forSelector:@selector(uuid)];
_items = [aDecoder scl_decodeArrayOfObjectsOfClass:[SCLLayoutConstraintItem class] forSelector:@selector(items)];


return self;
}

Expand Down Expand Up @@ -176,16 +177,11 @@ - (instancetype)copyWithZone:(NSZone *)zone

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
self = [self init];
if (!self) {
return nil;
}

_screen = [aDecoder scl_decodeObjectOfClass:[SCLScreen class] forSelector:@selector(screen)];
_anchor = [aDecoder scl_decodeCGPointForSelector:@selector(anchor)];
_rotation = [aDecoder scl_decodeCGFloatForSelector:@selector(rotation)];

return self;
SCLScreen *screen = [aDecoder scl_decodeObjectOfClass:[SCLScreen class] forSelector:@selector(screen)];
CGPoint anchor = [aDecoder scl_decodeCGPointForSelector:@selector(anchor)];
CGFloat rotation = [aDecoder scl_decodeCGFloatForSelector:@selector(rotation)];

return [self initWithScreen:screen anchor:anchor rotation:rotation];
}

- (void)encodeWithCoder:(NSCoder *)aCoder
Expand Down
2 changes: 2 additions & 0 deletions ScreenLayout/SCLSessionMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN

@interface SCLSessionMessage : NSObject <NSCopying, NSSecureCoding>

- (instancetype)init NS_UNAVAILABLE;

- (instancetype)initWithName:(nonnull NSString *)name object:(nullable id<NSObject, NSSecureCoding>)object;
- (instancetype)initWithName:(nonnull NSString *)name object:(nullable id<NSObject, NSSecureCoding>)object ofClasses:(nullable NSArray *)classes NS_DESIGNATED_INITIALIZER;

Expand Down
18 changes: 7 additions & 11 deletions ScreenLayout/SCLSessionMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,22 @@ - (instancetype)copyWithZone:(NSZone *)zone

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
self = [self init];
if (!self) {
return nil;
}

_name = [aDecoder scl_decodeObjectOfClass:[NSString class] forSelector:@selector(name)];
_classNames = [aDecoder scl_decodeObjectOfClasses:@[[NSSet class], [NSString class]] forSelector:@selector(classNames)];
NSString *name = [aDecoder scl_decodeObjectOfClass:[NSString class] forSelector:@selector(name)];
NSSet *classNames = [aDecoder scl_decodeObjectOfClasses:@[[NSSet class], [NSString class]] forSelector:@selector(classNames)];
id<NSObject, NSSecureCoding> object = nil;

NSMutableArray *classes = [[NSMutableArray alloc] init];
[_classNames enumerateObjectsUsingBlock:^(NSString *className, BOOL *stop) {
[classNames enumerateObjectsUsingBlock:^(NSString *className, BOOL *stop) {
Class class = NSClassFromString(className);
if (class) {
[classes addObject:class];
}
}];
if (classes.count > 0) {
_object = [aDecoder scl_decodeObjectOfClasses:classes forSelector:@selector(object)];
object = [aDecoder scl_decodeObjectOfClasses:classes forSelector:@selector(object)];
}
return self;

return [self initWithName:name object:object ofClasses:classes];
}

- (void)encodeWithCoder:(NSCoder *)aCoder
Expand Down

0 comments on commit 22ff97b

Please sign in to comment.