Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DISPATCH_SOURCE_TYPE_READ : file descriptor를 모니터한다.
- dispatch_queue_t globalQueue = dispatch_get_global_queue
- (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
- dispatch_source_t stdinSource
- = dispatch_source_create ( DISPATCH_SOURCE_TYPE_READ,
- STDIN_FILENO, //file descriptors
- 0,
- globalQueue );
- dispatch_source_set_event_handler ( stdinSource,
- ^{
- char buf[1024];
- int len = read(STDIN_FILENO, buf, sizeof(buf));
- if(len > 0)
- NSLog(@"Got data from stdin: %.*s", len, buf);
- });
- dispatch_resume(stdinSource);
Add Comment
Please, Sign In to add comment