Created
January 29, 2014 14:53
-
-
Save nevyn/8689661 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, mysocket, 0, dispatch_get_main_queue()); | |
dispatch_source_set_event_handler(_source, ^{ | |
// do something with mysocket, because it has changed (has read, write or error) | |
}; | |
dispatch_source_set_cancel_handler(source, ^{ | |
close(mysocket); | |
}); | |
dispatch_resume(_source); | |
// sen för att stänga socket: | |
dispatch_source_cancel(_source); | |
dispatch_release(_source); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment