All pastes #2074578 Raw Edit

Anonymous

public text v1 · immutable
#2074578 ·published 2011-06-04 12:55 UTC
rendered paste body
- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode {
    switch(eventCode) {
        case NSStreamEventHasBytesAvailable:
        {
            uint8_t buf[1];
            unsigned int len = 0;
            while ((len = (uint8_t)[(NSInputStream *)stream read:buf maxLength:1])) {
                if (buf[0] == 0x00 || buf[0] == 0x0A || buf[0] == 0x0D) continue;
                toProcess = [toProcess stringByAppendingFormat:@"%c", buf[0], nil];
                
                if ([toProcess hasSuffix:@"}"]) {
                    NSLog(@"LINE: %@", toProcess);
                    toProcess = @"";
                }
            }
            break;
        }
    }
}