changed iOS from using a byte array to using an NSData stream, to prevent unessisary reading of the stream ahead of time