We’ve touched on streaming approaches before, for example, when looking at the effects of memory mapping or when comparing DOM-based XML parsers to those based on SAX or MAX.
In the preceding chapter, we showed how to drastically lower memory consumption by changing the
description method that returns an
NSString to a streaming
describeOn: method that updates an
NSMutableString passed into it as an argument.
However, having the argument be an
NSMutableString seems to somewhat contradict our advice of having semantically rich objects, and also doesn’t solve the initial problem of an infinite recursion causing a crash. So it shouldn’t come as a surprise that we can do better. In fact, we will briefly introduce an ...