Skip to content

Commit cf4d87f

Browse files
committed
replaced id by instancetype and adjusted indentation
1 parent 620b613 commit cf4d87f

18 files changed

+158
-116
lines changed

NXOAuth2Account+Private.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515

1616
@interface NXOAuth2Account (Private)
1717

18-
- (id)initAccountWithOAuthClient:(NXOAuth2Client *)oauthClient accountType:(NSString *)accountType;
19-
- (id)initAccountWithAccessToken:(NXOAuth2AccessToken *)accessToken accountType:(NSString *)accountType;
18+
- (instancetype)initAccountWithOAuthClient:(NXOAuth2Client *)oauthClient
19+
accountType:(NSString *)accountType;
20+
21+
- (instancetype)initAccountWithAccessToken:(NXOAuth2AccessToken *)accessToken
22+
accountType:(NSString *)accountType;
2023

2124
@end

Sources/OAuth2Client/NXOAuth2AccessToken.h

+28-8
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,42 @@
3333
@property (nonatomic, readonly) NSSet *scope;
3434
@property (nonatomic, readonly) NSString *responseBody;
3535

36-
+ (id)tokenWithResponseBody:(NSString *)responseBody;
37-
+ (id)tokenWithResponseBody:(NSString *)responseBody tokenType:(NSString *)tokenType;
36+
+ (instancetype)tokenWithResponseBody:(NSString *)responseBody;
3837

39-
- (id)initWithAccessToken:(NSString *)accessToken;
40-
- (id)initWithAccessToken:(NSString *)accessToken refreshToken:(NSString *)refreshToken expiresAt:(NSDate *)expiryDate;
41-
- (id)initWithAccessToken:(NSString *)accessToken refreshToken:(NSString *)refreshToken expiresAt:(NSDate *)expiryDate scope:(NSSet *)scope;
42-
- (id)initWithAccessToken:(NSString *)accessToken refreshToken:(NSString *)refreshToken expiresAt:(NSDate *)expiryDate scope:(NSSet *)scope responseBody:(NSString *)responseBody;
43-
- (id)initWithAccessToken:(NSString *)accessToken refreshToken:(NSString *)refreshToken expiresAt:(NSDate *)expiryDate scope:(NSSet *)scope responseBody:(NSString *)responseBody tokenType:(NSString*)tokenType; // designated
38+
+ (instancetype)tokenWithResponseBody:(NSString *)responseBody
39+
tokenType:(NSString *)tokenType;
40+
41+
- (instancetype)initWithAccessToken:(NSString *)accessToken;
42+
43+
- (instancetype)initWithAccessToken:(NSString *)accessToken
44+
refreshToken:(NSString *)refreshToken
45+
expiresAt:(NSDate *)expiryDate;
46+
47+
- (instancetype)initWithAccessToken:(NSString *)accessToken
48+
refreshToken:(NSString *)refreshToken
49+
expiresAt:(NSDate *)expiryDate
50+
scope:(NSSet *)scope;
51+
52+
- (instancetype)initWithAccessToken:(NSString *)accessToken
53+
refreshToken:(NSString *)refreshToken
54+
expiresAt:(NSDate *)expiryDate
55+
scope:(NSSet *)scope
56+
responseBody:(NSString *)responseBody;
57+
58+
- (instancetype)initWithAccessToken:(NSString *)accessToken
59+
refreshToken:(NSString *)refreshToken
60+
expiresAt:(NSDate *)expiryDate
61+
scope:(NSSet *)scope
62+
responseBody:(NSString *)responseBody
63+
tokenType:(NSString*)tokenType; // designated
4464

4565
- (void)restoreWithOldToken:(NXOAuth2AccessToken *)oldToken;
4666

4767
#pragma mark Keychain Support
4868

4969
//TODO: Support alternate KeyChain Locations
5070

51-
+ (id)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
71+
+ (instancetype)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
5272
- (void)storeInDefaultKeychainWithServiceProviderName:(NSString *)provider;
5373
- (void)removeFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
5474

Sources/OAuth2Client/NXOAuth2AccessToken.m

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ @implementation NXOAuth2AccessToken
2020

2121
#pragma mark Lifecycle
2222

23-
+ (id)tokenWithResponseBody:(NSString *)theResponseBody;
23+
+ (instancetype)tokenWithResponseBody:(NSString *)theResponseBody;
2424
{
2525
return [self tokenWithResponseBody:theResponseBody tokenType:nil];
2626
}
2727

28-
+ (id)tokenWithResponseBody:(NSString *)theResponseBody tokenType:(NSString *)tokenType;
28+
+ (instancetype)tokenWithResponseBody:(NSString *)theResponseBody tokenType:(NSString *)tokenType;
2929
{
3030
NSDictionary *jsonDict = nil;
3131
Class jsonSerializationClass = NSClassFromString(@"NSJSONSerialization");
@@ -78,20 +78,20 @@ + (id)tokenWithResponseBody:(NSString *)theResponseBody tokenType:(NSString *)to
7878
tokenType:tokenType];
7979
}
8080

81-
- (id)initWithAccessToken:(NSString *)anAccessToken;
81+
- (instancetype)initWithAccessToken:(NSString *)anAccessToken;
8282
{
8383
return [self initWithAccessToken:anAccessToken refreshToken:nil expiresAt:nil];
8484
}
8585

86-
- (id)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate;
86+
- (instancetype)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate;
8787
{
8888
return [[[self class] alloc] initWithAccessToken:anAccessToken
8989
refreshToken:aRefreshToken
9090
expiresAt:anExpiryDate
9191
scope:nil];
9292
}
9393

94-
- (id)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate scope:(NSSet *)aScope;
94+
- (instancetype)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate scope:(NSSet *)aScope;
9595
{
9696
return [[[self class] alloc] initWithAccessToken:anAccessToken
9797
refreshToken:aRefreshToken
@@ -100,7 +100,7 @@ - (id)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRe
100100
responseBody:nil];
101101
}
102102

103-
- (id)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate scope:(NSSet *)aScope responseBody:(NSString *)aResponseBody;
103+
- (instancetype)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate scope:(NSSet *)aScope responseBody:(NSString *)aResponseBody;
104104
{
105105
return [[[self class] alloc] initWithAccessToken:anAccessToken
106106
refreshToken:aRefreshToken
@@ -110,7 +110,7 @@ - (id)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRe
110110
tokenType:nil];
111111
}
112112

113-
- (id)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate scope:(NSSet *)aScope responseBody:(NSString *)aResponseBody tokenType:(NSString *)aTokenType
113+
- (instancetype)initWithAccessToken:(NSString *)anAccessToken refreshToken:(NSString *)aRefreshToken expiresAt:(NSDate *)anExpiryDate scope:(NSSet *)aScope responseBody:(NSString *)aResponseBody tokenType:(NSString *)aTokenType
114114
{
115115
// a token object without an actual token is not what we want!
116116
NSAssert1(anAccessToken, @"No token from token response: %@", aResponseBody);
@@ -191,7 +191,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder
191191
}
192192
}
193193

194-
- (id)initWithCoder:(NSCoder *)aDecoder
194+
- (instancetype)initWithCoder:(NSCoder *)aDecoder
195195
{
196196
NSString *decodedAccessToken = [aDecoder decodeObjectForKey:@"accessToken"];
197197

@@ -224,7 +224,7 @@ + (NSString *)serviceNameWithProvider:(NSString *)provider;
224224

225225
#if TARGET_OS_IPHONE
226226

227-
+ (id)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
227+
+ (instancetype)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
228228
{
229229
NSString *serviceName = [[self class] serviceNameWithProvider:provider];
230230
NSDictionary *result = nil;
@@ -273,7 +273,7 @@ - (void)removeFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
273273

274274
#else
275275

276-
+ (id)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
276+
+ (instancetype)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider;
277277
{
278278
NSString *serviceName = [[self class] serviceNameWithProvider:provider];
279279

Sources/OAuth2Client/NXOAuth2Account.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ @implementation NXOAuth2Account (Private)
4141

4242
#pragma mark Lifecycle
4343

44-
- (id)initAccountWithOAuthClient:(NXOAuth2Client *)anOAuthClient accountType:(NSString *)anAccountType;
44+
- (instancetype)initAccountWithOAuthClient:(NXOAuth2Client *)anOAuthClient accountType:(NSString *)anAccountType;
4545
{
4646
self = [self initAccountWithAccessToken:anOAuthClient.accessToken
4747
accountType:anAccountType];
@@ -51,7 +51,7 @@ - (id)initAccountWithOAuthClient:(NXOAuth2Client *)anOAuthClient accountType:(NS
5151
return self;
5252
}
5353

54-
- (id)initAccountWithAccessToken:(NXOAuth2AccessToken *)anAccessToken accountType:(NSString *)anAccountType;
54+
- (instancetype)initAccountWithAccessToken:(NXOAuth2AccessToken *)anAccessToken accountType:(NSString *)anAccountType;
5555
{
5656
self = [super init];
5757
if (self) {
@@ -202,7 +202,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder
202202
[aCoder encodeObject:userData forKey:@"userData"];
203203
}
204204

205-
- (id)initWithCoder:(NSCoder *)aDecoder
205+
- (instancetype)initWithCoder:(NSCoder *)aDecoder
206206
{
207207
if (self = [super init]) {
208208
userData = [aDecoder decodeObjectForKey:@"userData"];

Sources/OAuth2Client/NXOAuth2AccountStore.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ typedef void(^NXOAuth2PreparedAuthorizationURLHandler)(NSURL *preparedURL);
7575
NSMutableDictionary *trustedCertificatesHandler;
7676
}
7777

78-
+ (id)sharedStore;
78+
+ (instancetype)sharedStore;
7979

8080
#pragma mark Accessors
8181

Sources/OAuth2Client/NXOAuth2AccountStore.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ @implementation NXOAuth2AccountStore
8787

8888
#pragma mark Lifecycle
8989

90-
+ (id)sharedStore;
90+
+ (instancetype)sharedStore;
9191
{
9292
static NXOAuth2AccountStore *shared;
9393
static dispatch_once_t onceToken;
@@ -97,7 +97,7 @@ + (id)sharedStore;
9797
return shared;
9898
}
9999

100-
- (id)init;
100+
- (instancetype)init;
101101
{
102102
self = [super init];
103103
if (self) {

Sources/OAuth2Client/NXOAuth2Client.h

+24-24
Original file line numberDiff line numberDiff line change
@@ -85,30 +85,30 @@ extern NSString * const NXOAuth2ClientConnectionContextTokenRefresh;
8585
/*!
8686
* Initializes the Client
8787
*/
88-
- (id)initWithClientID:(NSString *)clientId
89-
clientSecret:(NSString *)clientSecret
90-
authorizeURL:(NSURL *)authorizeURL
91-
tokenURL:(NSURL *)tokenURL
92-
delegate:(NSObject<NXOAuth2ClientDelegate> *)delegate;
93-
94-
- (id)initWithClientID:(NSString *)clientId
95-
clientSecret:(NSString *)clientSecret
96-
authorizeURL:(NSURL *)authorizeURL
97-
tokenURL:(NSURL *)tokenURL
98-
accessToken:(NXOAuth2AccessToken *)accessToken
99-
keyChainGroup:(NSString *)keyChainGroup
100-
persistent:(BOOL)shouldPersist
101-
delegate:(NSObject<NXOAuth2ClientDelegate> *)delegate;
102-
103-
- (id)initWithClientID:(NSString *)clientId
104-
clientSecret:(NSString *)clientSecret
105-
authorizeURL:(NSURL *)authorizeURL
106-
tokenURL:(NSURL *)tokenURL
107-
accessToken:(NXOAuth2AccessToken *)accessToken
108-
tokenType:(NSString *)tokenType
109-
keyChainGroup:(NSString *)keyChainGroup
110-
persistent:(BOOL)shouldPersist
111-
delegate:(NSObject<NXOAuth2ClientDelegate> *)delegate;
88+
- (instancetype)initWithClientID:(NSString *)clientId
89+
clientSecret:(NSString *)clientSecret
90+
authorizeURL:(NSURL *)authorizeURL
91+
tokenURL:(NSURL *)tokenURL
92+
delegate:(NSObject<NXOAuth2ClientDelegate> *)delegate;
93+
94+
- (instancetype)initWithClientID:(NSString *)clientId
95+
clientSecret:(NSString *)clientSecret
96+
authorizeURL:(NSURL *)authorizeURL
97+
tokenURL:(NSURL *)tokenURL
98+
accessToken:(NXOAuth2AccessToken *)accessToken
99+
keyChainGroup:(NSString *)keyChainGroup
100+
persistent:(BOOL)shouldPersist
101+
delegate:(NSObject<NXOAuth2ClientDelegate> *)delegate;
102+
103+
- (instancetype)initWithClientID:(NSString *)clientId
104+
clientSecret:(NSString *)clientSecret
105+
authorizeURL:(NSURL *)authorizeURL
106+
tokenURL:(NSURL *)tokenURL
107+
accessToken:(NXOAuth2AccessToken *)accessToken
108+
tokenType:(NSString *)tokenType
109+
keyChainGroup:(NSString *)keyChainGroup
110+
persistent:(BOOL)shouldPersist
111+
delegate:(NSObject<NXOAuth2ClientDelegate> *)delegate;
112112

113113
- (BOOL)openRedirectURL:(NSURL *)URL;
114114

Sources/OAuth2Client/NXOAuth2Client.m

+22-22
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ @implementation NXOAuth2Client
3737

3838
#pragma mark Lifecycle
3939

40-
- (id)initWithClientID:(NSString *)aClientId
41-
clientSecret:(NSString *)aClientSecret
42-
authorizeURL:(NSURL *)anAuthorizeURL
43-
tokenURL:(NSURL *)aTokenURL
44-
delegate:(NSObject<NXOAuth2ClientDelegate> *)aDelegate;
40+
- (instancetype)initWithClientID:(NSString *)aClientId
41+
clientSecret:(NSString *)aClientSecret
42+
authorizeURL:(NSURL *)anAuthorizeURL
43+
tokenURL:(NSURL *)aTokenURL
44+
delegate:(NSObject<NXOAuth2ClientDelegate> *)aDelegate;
4545
{
4646
return [self initWithClientID:aClientId
4747
clientSecret:aClientSecret
@@ -53,14 +53,14 @@ - (id)initWithClientID:(NSString *)aClientId
5353
delegate:aDelegate];
5454
}
5555

56-
- (id)initWithClientID:(NSString *)aClientId
57-
clientSecret:(NSString *)aClientSecret
58-
authorizeURL:(NSURL *)anAuthorizeURL
59-
tokenURL:(NSURL *)aTokenURL
60-
accessToken:(NXOAuth2AccessToken *)anAccessToken
61-
keyChainGroup:(NSString *)aKeyChainGroup
62-
persistent:(BOOL)shouldPersist
63-
delegate:(NSObject<NXOAuth2ClientDelegate> *)aDelegate;
56+
- (instancetype)initWithClientID:(NSString *)aClientId
57+
clientSecret:(NSString *)aClientSecret
58+
authorizeURL:(NSURL *)anAuthorizeURL
59+
tokenURL:(NSURL *)aTokenURL
60+
accessToken:(NXOAuth2AccessToken *)anAccessToken
61+
keyChainGroup:(NSString *)aKeyChainGroup
62+
persistent:(BOOL)shouldPersist
63+
delegate:(NSObject<NXOAuth2ClientDelegate> *)aDelegate;
6464
{
6565
return [self initWithClientID:aClientId
6666
clientSecret:aClientSecret
@@ -73,15 +73,15 @@ - (id)initWithClientID:(NSString *)aClientId
7373
delegate:aDelegate];
7474
}
7575

76-
- (id)initWithClientID:(NSString *)aClientId
77-
clientSecret:(NSString *)aClientSecret
78-
authorizeURL:(NSURL *)anAuthorizeURL
79-
tokenURL:(NSURL *)aTokenURL
80-
accessToken:(NXOAuth2AccessToken *)anAccessToken
81-
tokenType:(NSString *)aTokenType
82-
keyChainGroup:(NSString *)aKeyChainGroup
83-
persistent:(BOOL)shouldPersist
84-
delegate:(NSObject<NXOAuth2ClientDelegate> *)aDelegate;
76+
- (instancetype)initWithClientID:(NSString *)aClientId
77+
clientSecret:(NSString *)aClientSecret
78+
authorizeURL:(NSURL *)anAuthorizeURL
79+
tokenURL:(NSURL *)aTokenURL
80+
accessToken:(NXOAuth2AccessToken *)anAccessToken
81+
tokenType:(NSString *)aTokenType
82+
keyChainGroup:(NSString *)aKeyChainGroup
83+
persistent:(BOOL)shouldPersist
84+
delegate:(NSObject<NXOAuth2ClientDelegate> *)aDelegate;
8585
{
8686
NSAssert(aTokenURL != nil && anAuthorizeURL != nil, @"No token or no authorize URL");
8787
self = [super init];

Sources/OAuth2Client/NXOAuth2Connection.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ typedef void(^NXOAuth2ConnectionSendingProgressHandler)(unsigned long long bytes
8787
@property (nonatomic, strong) NSDictionary *userInfo;
8888
@property (nonatomic, strong, readonly) NXOAuth2Client *client;
8989

90-
- (id) initWithRequest:(NSMutableURLRequest *)request
91-
requestParameters:(NSDictionary *)requestParameters
92-
oauthClient:(NXOAuth2Client *)client
93-
sendingProgressHandler:(NXOAuth2ConnectionSendingProgressHandler)sendingProgressHandler
94-
responseHandler:(NXOAuth2ConnectionResponseHandler)responseHandler;
95-
96-
- (id)initWithRequest:(NSMutableURLRequest *)request
97-
requestParameters:(NSDictionary *)requestParameters
98-
oauthClient:(NXOAuth2Client *)client
99-
delegate:(NSObject<NXOAuth2ConnectionDelegate> *)delegate;
90+
- (instancetype) initWithRequest:(NSMutableURLRequest *)request
91+
requestParameters:(NSDictionary *)requestParameters
92+
oauthClient:(NXOAuth2Client *)client
93+
sendingProgressHandler:(NXOAuth2ConnectionSendingProgressHandler)sendingProgressHandler
94+
responseHandler:(NXOAuth2ConnectionResponseHandler)responseHandler;
95+
96+
- (instancetype)initWithRequest:(NSMutableURLRequest *)request
97+
requestParameters:(NSDictionary *)requestParameters
98+
oauthClient:(NXOAuth2Client *)client
99+
delegate:(NSObject<NXOAuth2ConnectionDelegate> *)delegate;
100100

101101
- (void)cancel;
102102

Sources/OAuth2Client/NXOAuth2Connection.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ - (id)initWithRequest:(NSMutableURLRequest *)aRequest
6464
return self;
6565
}
6666

67-
- (id)initWithRequest:(NSMutableURLRequest *)aRequest
68-
requestParameters:(NSDictionary *)someRequestParameters
69-
oauthClient:(NXOAuth2Client *)aClient
70-
delegate:(NSObject<NXOAuth2ConnectionDelegate> *)aDelegate;
67+
- (instancetype)initWithRequest:(NSMutableURLRequest *)aRequest
68+
requestParameters:(NSDictionary *)someRequestParameters
69+
oauthClient:(NXOAuth2Client *)aClient
70+
delegate:(NSObject<NXOAuth2ConnectionDelegate> *)aDelegate;
7171
{
7272
self = [super init];
7373
if (self) {

Sources/OAuth2Client/NXOAuth2FileStreamWrapper.h

+11-4
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,18 @@
2525
@property (nonatomic, copy, readonly) NSString *fileName;
2626
@property (nonatomic, copy) NSString *contentType; // optional DEFAULT: "application/octettstream"
2727

28-
+ (id)wrapperWithStream:(NSInputStream *)stream contentLength:(unsigned long long)contentLength DEPRECATED_ATTRIBUTE;
29-
- (id)initWithStream:(NSInputStream *)stream contentLength:(unsigned long long)contentLength DEPRECATED_ATTRIBUTE;
28+
+ (instancetype)wrapperWithStream:(NSInputStream *)stream
29+
contentLength:(unsigned long long)contentLength DEPRECATED_ATTRIBUTE;
3030

31-
+ (id)wrapperWithStream:(NSInputStream *)stream contentLength:(unsigned long long)contentLength fileName:(NSString *)fileName;
32-
- (id)initWithStream:(NSInputStream *)stream contentLength:(unsigned long long)contentLength fileName:(NSString *)fileName;
31+
- (instancetype)initWithStream:(NSInputStream *)stream
32+
contentLength:(unsigned long long)contentLength DEPRECATED_ATTRIBUTE;
3333

34+
+ (instancetype)wrapperWithStream:(NSInputStream *)stream
35+
contentLength:(unsigned long long)contentLength
36+
fileName:(NSString *)fileName;
37+
38+
- (instancetype)initWithStream:(NSInputStream *)stream
39+
contentLength:(unsigned long long)contentLength
40+
fileName:(NSString *)fileName;
3441

3542
@end

0 commit comments

Comments
 (0)