Merge pull request #1697 from wing328/objc_minor_style

[ObjC] minor style change for objc client
This commit is contained in:
wing328 2015-12-11 14:43:38 +08:00
commit 2a8afbec8d
11 changed files with 79 additions and 69 deletions

View File

@ -132,17 +132,20 @@ static void (^reachabilityChangeBlock)(int);
if (accepts == nil || [accepts count] == 0) { if (accepts == nil || [accepts count] == 0) {
return @""; return @"";
} }
NSMutableArray *lowerAccepts = [[NSMutableArray alloc] initWithCapacity:[accepts count]]; NSMutableArray *lowerAccepts = [[NSMutableArray alloc] initWithCapacity:[accepts count]];
for (NSString *string in accepts) { for (NSString *string in accepts) {
NSString * lowerAccept = [string lowercaseString]; NSString * lowerAccept = [string lowercaseString];
if([lowerAccept containsString:@"application/json"]) { if ([lowerAccept containsString:@"application/json"]) {
return @"application/json"; return @"application/json";
} }
[lowerAccepts addObject:lowerAccept]; [lowerAccepts addObject:lowerAccept];
} }
if(lowerAccepts.count == 1){
if (lowerAccepts.count == 1) {
return [lowerAccepts firstObject]; return [lowerAccepts firstObject];
} }
return [lowerAccepts componentsJoinedByString:@", "]; return [lowerAccepts componentsJoinedByString:@", "];
} }
@ -169,7 +172,7 @@ static void (^reachabilityChangeBlock)(int);
} }
+ (NSString*)escape:(id)unescaped { + (NSString*)escape:(id)unescaped {
if([unescaped isKindOfClass:[NSString class]]){ if ([unescaped isKindOfClass:[NSString class]]){
return (NSString *)CFBridgingRelease return (NSString *)CFBridgingRelease
(CFURLCreateStringByAddingPercentEscapes( (CFURLCreateStringByAddingPercentEscapes(
NULL, NULL,
@ -210,7 +213,7 @@ static void (^reachabilityChangeBlock)(int);
-(Boolean) executeRequestWithId:(NSNumber*) requestId { -(Boolean) executeRequestWithId:(NSNumber*) requestId {
NSSet* matchingItems = [queuedRequests objectsPassingTest:^BOOL(id obj, BOOL *stop) { NSSet* matchingItems = [queuedRequests objectsPassingTest:^BOOL(id obj, BOOL *stop) {
if([obj intValue] == [requestId intValue]) { if ([obj intValue] == [requestId intValue]) {
return YES; return YES;
} }
else { else {
@ -218,7 +221,7 @@ static void (^reachabilityChangeBlock)(int);
} }
}]; }];
if(matchingItems.count == 1) { if (matchingItems.count == 1) {
{{classPrefix}}DebugLog(@"removed request id %@", requestId); {{classPrefix}}DebugLog(@"removed request id %@", requestId);
[queuedRequests removeObject:requestId]; [queuedRequests removeObject:requestId];
return YES; return YES;
@ -266,7 +269,7 @@ static void (^reachabilityChangeBlock)(int);
} }
// call the reachability block, if configured // call the reachability block, if configured
if(reachabilityChangeBlock != nil) { if (reachabilityChangeBlock != nil) {
reachabilityChangeBlock(status); reachabilityChangeBlock(status);
} }
}]; }];
@ -408,16 +411,16 @@ static void (^reachabilityChangeBlock)(int);
completionBlock: (void (^)(id, NSError *))completionBlock { completionBlock: (void (^)(id, NSError *))completionBlock {
AFHTTPRequestOperation *op = [self HTTPRequestOperationWithRequest:request AFHTTPRequestOperation *op = [self HTTPRequestOperationWithRequest:request
success:^(AFHTTPRequestOperation *operation, id response) { success:^(AFHTTPRequestOperation *operation, id response) {
if([self executeRequestWithId:requestId]) { if ([self executeRequestWithId:requestId]) {
[self logResponse:operation forRequest:request error:nil]; [self logResponse:operation forRequest:request error:nil];
NSDictionary *responseHeaders = [[operation response] allHeaderFields]; NSDictionary *responseHeaders = [[operation response] allHeaderFields];
self.HTTPResponseHeaders = responseHeaders; self.HTTPResponseHeaders = responseHeaders;
completionBlock(response, nil); completionBlock(response, nil);
} }
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
if([self executeRequestWithId:requestId]) { if ([self executeRequestWithId:requestId]) {
NSMutableDictionary *userInfo = [error.userInfo mutableCopy]; NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
if(operation.responseObject) { if (operation.responseObject) {
// Add in the (parsed) response body. // Add in the (parsed) response body.
userInfo[{{classPrefix}}ResponseObjectErrorKey] = operation.responseObject; userInfo[{{classPrefix}}ResponseObjectErrorKey] = operation.responseObject;
} }
@ -588,10 +591,10 @@ static void (^reachabilityChangeBlock)(int);
// request cache // request cache
BOOL hasHeaderParams = false; BOOL hasHeaderParams = false;
if(headerParams != nil && [headerParams count] > 0) { if (headerParams != nil && [headerParams count] > 0) {
hasHeaderParams = true; hasHeaderParams = true;
} }
if(offlineState) { if (offlineState) {
{{classPrefix}}DebugLog(@"%@ cache forced", resourcePath); {{classPrefix}}DebugLog(@"%@ cache forced", resourcePath);
[request setCachePolicy:NSURLRequestReturnCacheDataDontLoad]; [request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
} }
@ -604,7 +607,7 @@ static void (^reachabilityChangeBlock)(int);
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
} }
if(hasHeaderParams){ if (hasHeaderParams){
for(NSString * key in [headerParams keyEnumerator]){ for(NSString * key in [headerParams keyEnumerator]){
[request setValue:[headerParams valueForKey:key] forHTTPHeaderField:key]; [request setValue:[headerParams valueForKey:key] forHTTPHeaderField:key];
} }
@ -637,36 +640,36 @@ static void (^reachabilityChangeBlock)(int);
int counter = 0; int counter = 0;
NSMutableString * requestUrl = [NSMutableString stringWithFormat:@"%@", path]; NSMutableString * requestUrl = [NSMutableString stringWithFormat:@"%@", path];
if(queryParams != nil){ if (queryParams != nil){
for(NSString * key in [queryParams keyEnumerator]){ for(NSString * key in [queryParams keyEnumerator]){
if(counter == 0) separator = @"?"; if (counter == 0) separator = @"?";
else separator = @"&"; else separator = @"&";
id queryParam = [queryParams valueForKey:key]; id queryParam = [queryParams valueForKey:key];
if([queryParam isKindOfClass:[NSString class]]){ if ([queryParam isKindOfClass:[NSString class]]){
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
[{{classPrefix}}ApiClient escape:key], [{{classPrefix}}ApiClient escape:[queryParams valueForKey:key]]]]; [{{classPrefix}}ApiClient escape:key], [{{classPrefix}}ApiClient escape:[queryParams valueForKey:key]]]];
} }
else if([queryParam isKindOfClass:[{{classPrefix}}QueryParamCollection class]]){ else if ([queryParam isKindOfClass:[{{classPrefix}}QueryParamCollection class]]){
{{classPrefix}}QueryParamCollection * coll = ({{classPrefix}}QueryParamCollection*) queryParam; {{classPrefix}}QueryParamCollection * coll = ({{classPrefix}}QueryParamCollection*) queryParam;
NSArray* values = [coll values]; NSArray* values = [coll values];
NSString* format = [coll format]; NSString* format = [coll format];
if([format isEqualToString:@"csv"]) { if ([format isEqualToString:@"csv"]) {
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
[{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@","]]]]; [{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@","]]]];
} }
else if([format isEqualToString:@"tsv"]) { else if ([format isEqualToString:@"tsv"]) {
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
[{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@"\t"]]]]; [{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@"\t"]]]];
} }
else if([format isEqualToString:@"pipes"]) { else if ([format isEqualToString:@"pipes"]) {
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
[{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@"|"]]]]; [{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@"|"]]]];
} }
else if([format isEqualToString:@"multi"]) { else if ([format isEqualToString:@"multi"]) {
for(id obj in values) { for(id obj in values) {
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
[{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", obj]]]; [{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", obj]]];

View File

@ -105,7 +105,7 @@ static {{classname}}* singletonAPI = nil;
{{/pathParams}} {{/pathParams}}
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
{{#queryParams}}if({{paramName}} != nil) { {{#queryParams}}if ({{paramName}} != nil) {
{{#collectionFormat}} {{#collectionFormat}}
queryParams[@"{{baseName}}"] = [[{{classPrefix}}QueryParamCollection alloc] initWithValuesAndFormat: {{baseName}} format: @"{{collectionFormat}}"]; queryParams[@"{{baseName}}"] = [[{{classPrefix}}QueryParamCollection alloc] initWithValuesAndFormat: {{baseName}} format: @"{{collectionFormat}}"];
{{/collectionFormat}} {{/collectionFormat}}
@ -114,7 +114,7 @@ static {{classname}}* singletonAPI = nil;
{{/queryParams}} {{/queryParams}}
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
{{#headerParams}}if({{paramName}} != nil) { {{#headerParams}}if ({{paramName}} != nil) {
headerParams[@"{{baseName}}"] = {{paramName}}; headerParams[@"{{baseName}}"] = {{paramName}};
} }
{{/headerParams}} {{/headerParams}}
@ -159,7 +159,7 @@ static {{classname}}* singletonAPI = nil;
{{#requiredParamCount}} {{#requiredParamCount}}
{{#requiredParams}} {{#requiredParams}}
if({{paramName}} == nil) { if ({{paramName}} == nil) {
// error // error
} }
{{/requiredParams}} {{/requiredParams}}

View File

@ -6,12 +6,13 @@
- (instancetype)init { - (instancetype)init {
self = [super init]; self = [super init];
if (self)
{ if (self) {
// initalise property's default value, if any // initalise property's default value, if any
{{#vars}}{{#defaultValue}}self.{{name}} = {{{defaultValue}}}; {{#vars}}{{#defaultValue}}self.{{name}} = {{{defaultValue}}};
{{/defaultValue}}{{/vars}} {{/defaultValue}}{{/vars}}
} }
return self; return self;
} }

View File

@ -128,24 +128,25 @@ static void (^reachabilityChangeBlock)(int);
/* /*
* Detect `Accept` from accepts * Detect `Accept` from accepts
*/ */
+ (NSString *) selectHeaderAccept:(NSArray *)accepts + (NSString *) selectHeaderAccept:(NSArray *)accepts {
{
if (accepts == nil || [accepts count] == 0) { if (accepts == nil || [accepts count] == 0) {
return @""; return @"";
} }
NSMutableArray *lowerAccepts = [[NSMutableArray alloc] initWithCapacity:[accepts count]]; NSMutableArray *lowerAccepts = [[NSMutableArray alloc] initWithCapacity:[accepts count]];
[accepts enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { for (NSString *string in accepts) {
[lowerAccepts addObject:[obj lowercaseString]]; NSString * lowerAccept = [string lowercaseString];
}]; if ([lowerAccept containsString:@"application/json"]) {
return @"application/json";
}
if ([lowerAccepts containsObject:@"application/json"]) { [lowerAccepts addObject:lowerAccept];
return @"application/json";
} }
else {
return [lowerAccepts componentsJoinedByString:@", "]; if (lowerAccepts.count == 1) {
return [lowerAccepts firstObject];
} }
return [lowerAccepts componentsJoinedByString:@", "];
} }
/* /*
@ -171,7 +172,7 @@ static void (^reachabilityChangeBlock)(int);
} }
+ (NSString*)escape:(id)unescaped { + (NSString*)escape:(id)unescaped {
if([unescaped isKindOfClass:[NSString class]]){ if ([unescaped isKindOfClass:[NSString class]]){
return (NSString *)CFBridgingRelease return (NSString *)CFBridgingRelease
(CFURLCreateStringByAddingPercentEscapes( (CFURLCreateStringByAddingPercentEscapes(
NULL, NULL,
@ -212,7 +213,7 @@ static void (^reachabilityChangeBlock)(int);
-(Boolean) executeRequestWithId:(NSNumber*) requestId { -(Boolean) executeRequestWithId:(NSNumber*) requestId {
NSSet* matchingItems = [queuedRequests objectsPassingTest:^BOOL(id obj, BOOL *stop) { NSSet* matchingItems = [queuedRequests objectsPassingTest:^BOOL(id obj, BOOL *stop) {
if([obj intValue] == [requestId intValue]) { if ([obj intValue] == [requestId intValue]) {
return YES; return YES;
} }
else { else {
@ -220,7 +221,7 @@ static void (^reachabilityChangeBlock)(int);
} }
}]; }];
if(matchingItems.count == 1) { if (matchingItems.count == 1) {
SWGDebugLog(@"removed request id %@", requestId); SWGDebugLog(@"removed request id %@", requestId);
[queuedRequests removeObject:requestId]; [queuedRequests removeObject:requestId];
return YES; return YES;
@ -268,7 +269,7 @@ static void (^reachabilityChangeBlock)(int);
} }
// call the reachability block, if configured // call the reachability block, if configured
if(reachabilityChangeBlock != nil) { if (reachabilityChangeBlock != nil) {
reachabilityChangeBlock(status); reachabilityChangeBlock(status);
} }
}]; }];
@ -410,16 +411,16 @@ static void (^reachabilityChangeBlock)(int);
completionBlock: (void (^)(id, NSError *))completionBlock { completionBlock: (void (^)(id, NSError *))completionBlock {
AFHTTPRequestOperation *op = [self HTTPRequestOperationWithRequest:request AFHTTPRequestOperation *op = [self HTTPRequestOperationWithRequest:request
success:^(AFHTTPRequestOperation *operation, id response) { success:^(AFHTTPRequestOperation *operation, id response) {
if([self executeRequestWithId:requestId]) { if ([self executeRequestWithId:requestId]) {
[self logResponse:operation forRequest:request error:nil]; [self logResponse:operation forRequest:request error:nil];
NSDictionary *responseHeaders = [[operation response] allHeaderFields]; NSDictionary *responseHeaders = [[operation response] allHeaderFields];
self.HTTPResponseHeaders = responseHeaders; self.HTTPResponseHeaders = responseHeaders;
completionBlock(response, nil); completionBlock(response, nil);
} }
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
if([self executeRequestWithId:requestId]) { if ([self executeRequestWithId:requestId]) {
NSMutableDictionary *userInfo = [error.userInfo mutableCopy]; NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
if(operation.responseObject) { if (operation.responseObject) {
// Add in the (parsed) response body. // Add in the (parsed) response body.
userInfo[SWGResponseObjectErrorKey] = operation.responseObject; userInfo[SWGResponseObjectErrorKey] = operation.responseObject;
} }
@ -590,10 +591,10 @@ static void (^reachabilityChangeBlock)(int);
// request cache // request cache
BOOL hasHeaderParams = false; BOOL hasHeaderParams = false;
if(headerParams != nil && [headerParams count] > 0) { if (headerParams != nil && [headerParams count] > 0) {
hasHeaderParams = true; hasHeaderParams = true;
} }
if(offlineState) { if (offlineState) {
SWGDebugLog(@"%@ cache forced", resourcePath); SWGDebugLog(@"%@ cache forced", resourcePath);
[request setCachePolicy:NSURLRequestReturnCacheDataDontLoad]; [request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
} }
@ -606,7 +607,7 @@ static void (^reachabilityChangeBlock)(int);
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
} }
if(hasHeaderParams){ if (hasHeaderParams){
for(NSString * key in [headerParams keyEnumerator]){ for(NSString * key in [headerParams keyEnumerator]){
[request setValue:[headerParams valueForKey:key] forHTTPHeaderField:key]; [request setValue:[headerParams valueForKey:key] forHTTPHeaderField:key];
} }
@ -639,36 +640,36 @@ static void (^reachabilityChangeBlock)(int);
int counter = 0; int counter = 0;
NSMutableString * requestUrl = [NSMutableString stringWithFormat:@"%@", path]; NSMutableString * requestUrl = [NSMutableString stringWithFormat:@"%@", path];
if(queryParams != nil){ if (queryParams != nil){
for(NSString * key in [queryParams keyEnumerator]){ for(NSString * key in [queryParams keyEnumerator]){
if(counter == 0) separator = @"?"; if (counter == 0) separator = @"?";
else separator = @"&"; else separator = @"&";
id queryParam = [queryParams valueForKey:key]; id queryParam = [queryParams valueForKey:key];
if([queryParam isKindOfClass:[NSString class]]){ if ([queryParam isKindOfClass:[NSString class]]){
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
[SWGApiClient escape:key], [SWGApiClient escape:[queryParams valueForKey:key]]]]; [SWGApiClient escape:key], [SWGApiClient escape:[queryParams valueForKey:key]]]];
} }
else if([queryParam isKindOfClass:[SWGQueryParamCollection class]]){ else if ([queryParam isKindOfClass:[SWGQueryParamCollection class]]){
SWGQueryParamCollection * coll = (SWGQueryParamCollection*) queryParam; SWGQueryParamCollection * coll = (SWGQueryParamCollection*) queryParam;
NSArray* values = [coll values]; NSArray* values = [coll values];
NSString* format = [coll format]; NSString* format = [coll format];
if([format isEqualToString:@"csv"]) { if ([format isEqualToString:@"csv"]) {
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
[SWGApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@","]]]]; [SWGApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@","]]]];
} }
else if([format isEqualToString:@"tsv"]) { else if ([format isEqualToString:@"tsv"]) {
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
[SWGApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@"\t"]]]]; [SWGApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@"\t"]]]];
} }
else if([format isEqualToString:@"pipes"]) { else if ([format isEqualToString:@"pipes"]) {
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
[SWGApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@"|"]]]]; [SWGApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@"|"]]]];
} }
else if([format isEqualToString:@"multi"]) { else if ([format isEqualToString:@"multi"]) {
for(id obj in values) { for(id obj in values) {
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
[SWGApiClient escape:key], [NSString stringWithFormat:@"%@", obj]]]; [SWGApiClient escape:key], [NSString stringWithFormat:@"%@", obj]]];

View File

@ -4,11 +4,12 @@
- (instancetype)init { - (instancetype)init {
self = [super init]; self = [super init];
if (self)
{ if (self) {
// initalise property's default value, if any // initalise property's default value, if any
} }
return self; return self;
} }

View File

@ -4,11 +4,12 @@
- (instancetype)init { - (instancetype)init {
self = [super init]; self = [super init];
if (self)
{ if (self) {
// initalise property's default value, if any // initalise property's default value, if any
} }
return self; return self;
} }

View File

@ -4,11 +4,12 @@
- (instancetype)init { - (instancetype)init {
self = [super init]; self = [super init];
if (self)
{ if (self) {
// initalise property's default value, if any // initalise property's default value, if any
} }
return self; return self;
} }

View File

@ -250,7 +250,7 @@ static SWGPetApi* singletonAPI = nil;
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
if(status != nil) { if (status != nil) {
queryParams[@"status"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: status format: @"multi"]; queryParams[@"status"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: status format: @"multi"];
@ -334,7 +334,7 @@ static SWGPetApi* singletonAPI = nil;
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
if(tags != nil) { if (tags != nil) {
queryParams[@"tags"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: tags format: @"multi"]; queryParams[@"tags"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: tags format: @"multi"];
@ -622,7 +622,7 @@ static SWGPetApi* singletonAPI = nil;
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders]; NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
if(apiKey != nil) { if (apiKey != nil) {
headerParams[@"api_key"] = apiKey; headerParams[@"api_key"] = apiKey;
} }

View File

@ -4,11 +4,12 @@
- (instancetype)init { - (instancetype)init {
self = [super init]; self = [super init];
if (self)
{ if (self) {
// initalise property's default value, if any // initalise property's default value, if any
} }
return self; return self;
} }

View File

@ -4,11 +4,12 @@
- (instancetype)init { - (instancetype)init {
self = [super init]; self = [super init];
if (self)
{ if (self) {
// initalise property's default value, if any // initalise property's default value, if any
} }
return self; return self;
} }

View File

@ -331,11 +331,11 @@ static SWGUserApi* singletonAPI = nil;
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
if(username != nil) { if (username != nil) {
queryParams[@"username"] = username; queryParams[@"username"] = username;
} }
if(password != nil) { if (password != nil) {
queryParams[@"password"] = password; queryParams[@"password"] = password;
} }