From 778a1aa9c7a93ecd90fcfc7b2a621b392370f7f8 Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Thu, 15 Oct 2015 11:01:37 -0700 Subject: [PATCH] Use `instancetype` where applicable --- AFNetworking/AFHTTPSessionManager.m | 4 +-- AFNetworking/AFSecurityPolicy.m | 2 +- AFNetworking/AFURLRequestSerialization.m | 30 +++++++++---------- AFNetworking/AFURLResponseSerialization.m | 24 +++++++-------- AFNetworking/AFURLSessionManager.m | 4 +-- Example/iOS Example/Views/PostTableViewCell.m | 2 +- .../AFNetworkActivityIndicatorManager.m | 2 +- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/AFNetworking/AFHTTPSessionManager.m b/AFNetworking/AFHTTPSessionManager.m index 99d45ccdbe..f60846585f 100644 --- a/AFNetworking/AFHTTPSessionManager.m +++ b/AFNetworking/AFHTTPSessionManager.m @@ -268,7 +268,7 @@ + (BOOL)supportsSecureCoding { return YES; } -- (id)initWithCoder:(NSCoder *)decoder { +- (instancetype)initWithCoder:(NSCoder *)decoder { NSURL *baseURL = [decoder decodeObjectOfClass:[NSURL class] forKey:NSStringFromSelector(@selector(baseURL))]; NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; if (!configuration) { @@ -308,7 +308,7 @@ - (void)encodeWithCoder:(NSCoder *)coder { #pragma mark - NSCopying -- (id)copyWithZone:(NSZone *)zone { +- (instancetype)copyWithZone:(NSZone *)zone { AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration]; HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; diff --git a/AFNetworking/AFSecurityPolicy.m b/AFNetworking/AFSecurityPolicy.m index 3819e0ae88..fb6e29ea5f 100644 --- a/AFNetworking/AFSecurityPolicy.m +++ b/AFNetworking/AFSecurityPolicy.m @@ -198,7 +198,7 @@ + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCe return securityPolicy; } -- (id)init { +- (instancetype)init { self = [super init]; if (!self) { return nil; diff --git a/AFNetworking/AFURLRequestSerialization.m b/AFNetworking/AFURLRequestSerialization.m index 44dacd9497..5f2d107b24 100644 --- a/AFNetworking/AFURLRequestSerialization.m +++ b/AFNetworking/AFURLRequestSerialization.m @@ -111,14 +111,14 @@ @interface AFQueryStringPair : NSObject @property (readwrite, nonatomic, strong) id field; @property (readwrite, nonatomic, strong) id value; -- (id)initWithField:(id)field value:(id)value; +- (instancetype)initWithField:(id)field value:(id)value; - (NSString *)URLEncodedStringValue; @end @implementation AFQueryStringPair -- (id)initWithField:(id)field value:(id)value { +- (instancetype)initWithField:(id)field value:(id)value { self = [super init]; if (!self) { return nil; @@ -591,7 +591,7 @@ + (BOOL)supportsSecureCoding { return YES; } -- (id)initWithCoder:(NSCoder *)decoder { +- (instancetype)initWithCoder:(NSCoder *)decoder { self = [self init]; if (!self) { return nil; @@ -610,7 +610,7 @@ - (void)encodeWithCoder:(NSCoder *)coder { #pragma mark - NSCopying -- (id)copyWithZone:(NSZone *)zone { +- (instancetype)copyWithZone:(NSZone *)zone { AFHTTPRequestSerializer *serializer = [[[self class] allocWithZone:zone] init]; serializer.mutableHTTPRequestHeaders = [self.mutableHTTPRequestHeaders mutableCopyWithZone:zone]; serializer.queryStringSerializationStyle = self.queryStringSerializationStyle; @@ -684,7 +684,7 @@ @interface AFMultipartBodyStream : NSInputStream @property (readonly, nonatomic, assign) unsigned long long contentLength; @property (readonly, nonatomic, assign, getter = isEmpty) BOOL empty; -- (id)initWithStringEncoding:(NSStringEncoding)encoding; +- (instancetype)initWithStringEncoding:(NSStringEncoding)encoding; - (void)setInitialAndFinalBoundaries; - (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart; @end @@ -700,8 +700,8 @@ @interface AFStreamingMultipartFormData () @implementation AFStreamingMultipartFormData -- (id)initWithURLRequest:(NSMutableURLRequest *)urlRequest - stringEncoding:(NSStringEncoding)encoding +- (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding { self = [super init]; if (!self) { @@ -893,7 +893,7 @@ @implementation AFMultipartBodyStream @synthesize streamError; #pragma clang diagnostic pop -- (id)initWithStringEncoding:(NSStringEncoding)encoding { +- (instancetype)initWithStringEncoding:(NSStringEncoding)encoding { self = [super init]; if (!self) { return nil; @@ -1036,7 +1036,7 @@ - (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags #pragma mark - NSCopying --(id)copyWithZone:(NSZone *)zone { +- (instancetype)copyWithZone:(NSZone *)zone { AFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { @@ -1073,7 +1073,7 @@ - (NSInteger)readData:(NSData *)data @implementation AFHTTPBodyPart -- (id)init { +- (instancetype)init { self = [super init]; if (!self) { return nil; @@ -1251,7 +1251,7 @@ - (BOOL)transitionToNextPhase { #pragma mark - NSCopying -- (id)copyWithZone:(NSZone *)zone { +- (instancetype)copyWithZone:(NSZone *)zone { AFHTTPBodyPart *bodyPart = [[[self class] allocWithZone:zone] init]; bodyPart.stringEncoding = self.stringEncoding; @@ -1314,7 +1314,7 @@ - (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request #pragma mark - NSSecureCoding -- (id)initWithCoder:(NSCoder *)decoder { +- (instancetype)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (!self) { return nil; @@ -1333,7 +1333,7 @@ - (void)encodeWithCoder:(NSCoder *)coder { #pragma mark - NSCopying -- (id)copyWithZone:(NSZone *)zone { +- (instancetype)copyWithZone:(NSZone *)zone { AFJSONRequestSerializer *serializer = [super copyWithZone:zone]; serializer.writingOptions = self.writingOptions; @@ -1393,7 +1393,7 @@ - (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request #pragma mark - NSSecureCoding -- (id)initWithCoder:(NSCoder *)decoder { +- (instancetype)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (!self) { return nil; @@ -1414,7 +1414,7 @@ - (void)encodeWithCoder:(NSCoder *)coder { #pragma mark - NSCopying -- (id)copyWithZone:(NSZone *)zone { +- (instancetype)copyWithZone:(NSZone *)zone { AFPropertyListRequestSerializer *serializer = [super copyWithZone:zone]; serializer.format = self.format; serializer.writeOptions = self.writeOptions; diff --git a/AFNetworking/AFURLResponseSerialization.m b/AFNetworking/AFURLResponseSerialization.m index 6d67889c0e..a7ecc87b4d 100644 --- a/AFNetworking/AFURLResponseSerialization.m +++ b/AFNetworking/AFURLResponseSerialization.m @@ -173,7 +173,7 @@ + (BOOL)supportsSecureCoding { return YES; } -- (id)initWithCoder:(NSCoder *)decoder { +- (instancetype)initWithCoder:(NSCoder *)decoder { self = [self init]; if (!self) { return nil; @@ -192,7 +192,7 @@ - (void)encodeWithCoder:(NSCoder *)coder { #pragma mark - NSCopying -- (id)copyWithZone:(NSZone *)zone { +- (instancetype)copyWithZone:(NSZone *)zone { AFHTTPResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; serializer.acceptableStatusCodes = [self.acceptableStatusCodes copyWithZone:zone]; serializer.acceptableContentTypes = [self.acceptableContentTypes copyWithZone:zone]; @@ -289,7 +289,7 @@ - (id)responseObjectForResponse:(NSURLResponse *)response #pragma mark - NSSecureCoding -- (id)initWithCoder:(NSCoder *)decoder { +- (instancetype)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (!self) { return nil; @@ -310,7 +310,7 @@ - (void)encodeWithCoder:(NSCoder *)coder { #pragma mark - NSCopying -- (id)copyWithZone:(NSZone *)zone { +- (instancetype)copyWithZone:(NSZone *)zone { AFJSONResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; serializer.readingOptions = self.readingOptions; serializer.removesKeysWithNullValues = self.removesKeysWithNullValues; @@ -410,7 +410,7 @@ - (id)responseObjectForResponse:(NSURLResponse *)response #pragma mark - NSSecureCoding -- (id)initWithCoder:(NSCoder *)decoder { +- (instancetype)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (!self) { return nil; @@ -429,7 +429,7 @@ - (void)encodeWithCoder:(NSCoder *)coder { #pragma mark - NSCopying -- (id)copyWithZone:(NSZone *)zone { +- (instancetype)copyWithZone:(NSZone *)zone { AFXMLDocumentResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; serializer.options = self.options; @@ -497,7 +497,7 @@ - (id)responseObjectForResponse:(NSURLResponse *)response #pragma mark - NSSecureCoding -- (id)initWithCoder:(NSCoder *)decoder { +- (instancetype)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (!self) { return nil; @@ -518,7 +518,7 @@ - (void)encodeWithCoder:(NSCoder *)coder { #pragma mark - NSCopying -- (id)copyWithZone:(NSZone *)zone { +- (instancetype)copyWithZone:(NSZone *)zone { AFPropertyListResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; serializer.format = self.format; serializer.readOptions = self.readOptions; @@ -713,7 +713,7 @@ - (id)responseObjectForResponse:(NSURLResponse *)response #pragma mark - NSSecureCoding -- (id)initWithCoder:(NSCoder *)decoder { +- (instancetype)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (!self) { return nil; @@ -744,7 +744,7 @@ - (void)encodeWithCoder:(NSCoder *)coder { #pragma mark - NSCopying -- (id)copyWithZone:(NSZone *)zone { +- (instancetype)copyWithZone:(NSZone *)zone { AFImageResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; #if TARGET_OS_IOS || TARGET_OS_TV @@ -799,7 +799,7 @@ - (id)responseObjectForResponse:(NSURLResponse *)response #pragma mark - NSSecureCoding -- (id)initWithCoder:(NSCoder *)decoder { +- (instancetype)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (!self) { return nil; @@ -818,7 +818,7 @@ - (void)encodeWithCoder:(NSCoder *)coder { #pragma mark - NSCopying -- (id)copyWithZone:(NSZone *)zone { +- (instancetype)copyWithZone:(NSZone *)zone { AFCompoundResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; serializer.responseSerializers = self.responseSerializers; diff --git a/AFNetworking/AFURLSessionManager.m b/AFNetworking/AFURLSessionManager.m index d387ffc0d6..07dbf4ea7f 100644 --- a/AFNetworking/AFURLSessionManager.m +++ b/AFNetworking/AFURLSessionManager.m @@ -1154,7 +1154,7 @@ + (BOOL)supportsSecureCoding { return YES; } -- (id)initWithCoder:(NSCoder *)decoder { +- (instancetype)initWithCoder:(NSCoder *)decoder { NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; self = [self initWithSessionConfiguration:configuration]; @@ -1171,7 +1171,7 @@ - (void)encodeWithCoder:(NSCoder *)coder { #pragma mark - NSCopying -- (id)copyWithZone:(NSZone *)zone { +- (instancetype)copyWithZone:(NSZone *)zone { return [[[self class] allocWithZone:zone] initWithSessionConfiguration:self.session.configuration]; } diff --git a/Example/iOS Example/Views/PostTableViewCell.m b/Example/iOS Example/Views/PostTableViewCell.m index 14a31ad7e6..8fb0210f15 100644 --- a/Example/iOS Example/Views/PostTableViewCell.m +++ b/Example/iOS Example/Views/PostTableViewCell.m @@ -29,7 +29,7 @@ @implementation PostTableViewCell -- (id)initWithStyle:(UITableViewCellStyle)style +- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; diff --git a/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m b/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m index 99ac41a5f9..9f03f55935 100644 --- a/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m +++ b/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m @@ -60,7 +60,7 @@ + (NSSet *)keyPathsForValuesAffectingIsNetworkActivityIndicatorVisible { return [NSSet setWithObject:@"activityCount"]; } -- (id)init { +- (instancetype)init { self = [super init]; if (!self) { return nil;