Created
October 11, 2012 09:42
-
-
Save alex-cellcity/3871297 to your computer and use it in GitHub Desktop.
gcd get ipaddress
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
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul); | |
dispatch_async(queue, ^{ | |
NSString *ipaddress = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://ifconfig.me/ip"] encoding:NSUTF8StringEncoding error:NULL]; | |
dispatch_sync(dispatch_get_main_queue(), ^{ | |
[response respondWith:ipaddress]; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment