Skip to content

Commit

Permalink
Use instancetype where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
kylef committed Oct 15, 2015
1 parent 945f976 commit 778a1aa
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions AFNetworking/AFHTTPSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion AFNetworking/AFSecurityPolicy.m
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCe
return securityPolicy;
}

- (id)init {
- (instancetype)init {
self = [super init];
if (!self) {
return nil;
Expand Down
30 changes: 15 additions & 15 deletions AFNetworking/AFURLRequestSerialization.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -591,7 +591,7 @@ + (BOOL)supportsSecureCoding {
return YES;
}

- (id)initWithCoder:(NSCoder *)decoder {
- (instancetype)initWithCoder:(NSCoder *)decoder {
self = [self init];
if (!self) {
return nil;
Expand All @@ -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;
Expand Down Expand Up @@ -684,7 +684,7 @@ @interface AFMultipartBodyStream : NSInputStream <NSStreamDelegate>
@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
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1073,7 +1073,7 @@ - (NSInteger)readData:(NSData *)data

@implementation AFHTTPBodyPart

- (id)init {
- (instancetype)init {
self = [super init];
if (!self) {
return nil;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
24 changes: 12 additions & 12 deletions AFNetworking/AFURLResponseSerialization.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ + (BOOL)supportsSecureCoding {
return YES;
}

- (id)initWithCoder:(NSCoder *)decoder {
- (instancetype)initWithCoder:(NSCoder *)decoder {
self = [self init];
if (!self) {
return nil;
Expand All @@ -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];
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions AFNetworking/AFURLSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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];
}

Expand Down
2 changes: 1 addition & 1 deletion Example/iOS Example/Views/PostTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

@implementation PostTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style
- (instancetype)initWithStyle:(UITableViewCellStyle)style
reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
Expand Down
2 changes: 1 addition & 1 deletion UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ + (NSSet *)keyPathsForValuesAffectingIsNetworkActivityIndicatorVisible {
return [NSSet setWithObject:@"activityCount"];
}

- (id)init {
- (instancetype)init {
self = [super init];
if (!self) {
return nil;
Expand Down

0 comments on commit 778a1aa

Please sign in to comment.