Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A simple example of an NSInputStream subclass that will work correctly with NSURLRequest and CFHTTPMessageRef

branch: master

Maintain the delegate contract.

NSStream requires that the delegate should
default to `self` if no other delegate has
been set.
latest commit 2887a992e9
BJ Homer authored March 01, 2012
Octocat-spinner-32 HSCountingInputStream.xcodeproj Add HSRandomDataInputStream May 11, 2011
Octocat-spinner-32 HSCountingInputStream Maintain the delegate contract. March 01, 2012
Octocat-spinner-32 README.md Add readme. April 14, 2011
README.md

HSCountingInputStream is a simple example of an NSInputStream subclass that works around the bugs you'll run into if you try to pass such a subclass to NSURLRequest or CFHTTPMessageRef. See my blog for more information on the gory details of how it works.

Note:

This sample uses a few language features only available if you're using Xcode 4 and the LLVM Compiler 2.0, such as instance variables defined in the @implementation block. It also relies on the modern runtime to synthesize the instance variables. I used these features because they're cool and I wanted people to be aware of them.

So if it won't compile for you, that's probably why. It shouldn't be hard to make the necessary changes to make it work for x86 or GCC 4.2, if that's what you need to do.

Something went wrong with that request. Please try again.