From 03687ad96de1f12b913450d240c8a3084c6ef87b Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Tue, 14 Jul 2015 16:53:38 -0400 Subject: [PATCH] Obj-C generics --- SuperSocket/SuperSocket/STCPSocket.m | 2 +- SuperSocket/SuperSocket/SUDPSendPacket.h | 2 +- SuperSocket/SuperSocket/SUDPSocket.m | 16 +++++++--------- SuperSocket/SuperSocket/SUDPSpecialPacket.h | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/SuperSocket/SuperSocket/STCPSocket.m b/SuperSocket/SuperSocket/STCPSocket.m index 6d6c043f..c8c1089b 100644 --- a/SuperSocket/SuperSocket/STCPSocket.m +++ b/SuperSocket/SuperSocket/STCPSocket.m @@ -2464,7 +2464,7 @@ - (void)getInterfaceAddress4:(NSMutableData **)interfaceAddr4Ptr NSString *interface = nil; - NSArray *components = [interfaceDescription componentsSeparatedByString:@":"]; + NSArray *components = [interfaceDescription componentsSeparatedByString:@":"]; if ([components count] > 0) { NSString *temp = [components objectAtIndex:0]; if ([temp length] > 0) { diff --git a/SuperSocket/SuperSocket/SUDPSendPacket.h b/SuperSocket/SuperSocket/SUDPSendPacket.h index 41ac0c0f..a1c5c666 100644 --- a/SuperSocket/SuperSocket/SUDPSendPacket.h +++ b/SuperSocket/SuperSocket/SUDPSendPacket.h @@ -20,7 +20,7 @@ BOOL resolveInProgress; BOOL filterInProgress; - NSArray *resolvedAddresses; + NSArray *resolvedAddresses; NSError *resolveError; NSData *address; diff --git a/SuperSocket/SuperSocket/SUDPSocket.m b/SuperSocket/SuperSocket/SUDPSocket.m index 702225b0..59d0238a 100644 --- a/SuperSocket/SuperSocket/SUDPSocket.m +++ b/SuperSocket/SuperSocket/SUDPSocket.m @@ -997,7 +997,7 @@ - (BOOL)preOp:(NSError **)errPtr { **/ - (void)asyncResolveHost:(NSString *)aHost port:(uint16_t)port - withCompletionBlock:(void (^)(NSArray *addresses, NSError *error))completionBlock { + withCompletionBlock:(void (^)(NSArray *addresses, NSError *error))completionBlock { LogTrace(); // Check parameter(s) @@ -1020,10 +1020,8 @@ - (void)asyncResolveHost:(NSString *)aHost // It's possible that the given aHost parameter is actually a NSMutableString. // So we want to copy it now, within this block that will be executed synchronously. // This way the asynchronous lookup block below doesn't have to worry about it changing. - NSString *host = [aHost copy]; - dispatch_queue_t globalConcurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(globalConcurrentQueue, ^{ @autoreleasepool { @@ -1103,7 +1101,7 @@ - (void)asyncResolveHost:(NSString *)aHost * Returns the address family (AF_INET or AF_INET6) of the picked address, * or AF_UNSPEC and the corresponding error is there's a problem. **/ -- (int)getAddress:(NSData **)addressPtr error:(NSError **)errorPtr fromAddresses:(NSArray *)addresses { +- (int)getAddress:(NSData **)addressPtr error:(NSError **)errorPtr fromAddresses:(NSArray *)addresses { NSAssert(dispatch_get_specific(IsOnSocketQueueOrTargetQueueKey), @"Must be dispatched on socketQueue"); NSAssert([addresses count] > 0, @"Expected at least one address"); @@ -2757,8 +2755,8 @@ - (BOOL)connectToHost:(NSString *)host onPort:(uint16_t)port error:(NSError **)e LogVerbose(@"Dispatching DNS resolve for connect..."); [self asyncResolveHost:host - port:port - withCompletionBlock:^(NSArray *addresses, NSError *error) { + port:port + withCompletionBlock:^(NSArray *addresses, NSError *error) { // The asyncResolveHost:port:: method asynchronously dispatches a task onto the global concurrent queue, // and immediately returns. Once the async resolve task completes, @@ -2830,7 +2828,7 @@ - (BOOL)connectToAddress:(NSData *)remoteAddr error:(NSError **)errPtr { // So we copy it to be safe. NSData *address = [remoteAddr copy]; - NSArray *addresses = [NSArray arrayWithObject:address]; + NSArray *addresses = @[address]; SUDPSpecialPacket *packet = [[SUDPSpecialPacket alloc] init]; packet->addresses = addresses; @@ -3191,8 +3189,8 @@ - (void)sendData:(NSData *)data packet->resolveInProgress = YES; [self asyncResolveHost:host - port:port - withCompletionBlock:^(NSArray *addresses, NSError *error) { + port:port + withCompletionBlock:^(NSArray *addresses, NSError *error) { // The asyncResolveHost:port:: method asynchronously dispatches a task onto the global concurrent queue, // and immediately returns. Once the async resolve task completes, diff --git a/SuperSocket/SuperSocket/SUDPSpecialPacket.h b/SuperSocket/SuperSocket/SUDPSpecialPacket.h index 464d9432..4fa650df 100644 --- a/SuperSocket/SuperSocket/SUDPSpecialPacket.h +++ b/SuperSocket/SuperSocket/SUDPSpecialPacket.h @@ -14,7 +14,7 @@ BOOL resolveInProgress; - NSArray *addresses; + NSArray *addresses; NSError *error; }