Created
March 4, 2016 04:05
-
-
Save phucnm/712faf4584c5baa9a84f to your computer and use it in GitHub Desktop.
Get IP NSString from address data in iOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <arpa/inet.h> | |
- (NSString *)getStringFromAddressData:(NSData *)dataIn { | |
struct sockaddr_in *socketAddress = nil; | |
NSString *ipString = nil; | |
socketAddress = (struct sockaddr_in *)[dataIn bytes]; | |
ipString = [NSString stringWithFormat: @"%s", | |
inet_ntoa(socketAddress->sin_addr)]; ///problem here | |
return ipString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment