Skip to content

Instantly share code, notes, and snippets.

@alex-cellcity
Created October 11, 2012 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alex-cellcity/3871297 to your computer and use it in GitHub Desktop.
Save alex-cellcity/3871297 to your computer and use it in GitHub Desktop.
gcd get ipaddress
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