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,6 +132,7 @@ 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];
@ -140,9 +141,11 @@ static void (^reachabilityChangeBlock)(int);
} }
[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:@", "];
} }

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"]) {
if ([lowerAccepts containsObject:@"application/json"]) {
return @"application/json"; return @"application/json";
} }
else { [lowerAccepts addObject:lowerAccept];
return [lowerAccepts componentsJoinedByString:@", "];
} }
if (lowerAccepts.count == 1) {
return [lowerAccepts firstObject];
}
return [lowerAccepts componentsJoinedByString:@", "];
} }
/* /*

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

@ -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;
} }