Hey all!
I'm using ASyncSocket to move some UIImages from one device over to another.
Essentially, on one device I have:
NSMutableData *data = UIImageJPEGRepresentation(image, 0.1);
if(isRunning){
[sock writeData:data withTimeout:-1 tag:0];
}
So a new image will be added to the socket every so often (like a webcam).
Then, on the other device, I am calling:
[listenSocket readDataWithTimeout:1 tag:0];
which will respond with:
- (void)onSocket:(AsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag
{
[responseData appendData:data];
[listenSocket readDataWithTimeout:1 tag:0];
}
Essentially, what I want to be able to do is have an NSTimer going which will call @selector(PullImages):
-(void) PullImages {
In here, I want to be able to pull images out of ResponseData. How do I do that? There might not be a complete image yet, there might be multiple images, there might be one and a half images!
I want to parse the NSData into each existing image!
}
Any assistance? Thanks in advance!