Skip to content

Instantly share code, notes, and snippets.

@mdippery

mdippery/main.m Secret

Created January 12, 2011 23:03
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 mdippery/afd0ce88d3732c36a93b to your computer and use it in GitHub Desktop.
Save mdippery/afd0ce88d3732c36a93b to your computer and use it in GitHub Desktop.
A test driver for my FileTailer class
#import <Foundation/Foundation.h>
#import "FileTailer.h"
#include <stdio.h>
int main(int argc, char **argv)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
FILE *in = stdin;
if (argc > 1) {
in = fopen(argv[1], "r");
if (!in) {
fprintf(stderr, "Could not open file: %s\n", argv[1]);
[pool release];
return 1;
}
}
FileTailer *tail = [[[FileTailer alloc] initWithStream:in refreshPeriod:3.0] autorelease];
[tail readIndefinitely:^ void (int ch) { printf("%c", ch); }];
[pool release];
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment