O'Reilly logo

iOS and macOS™ Performance Tuning: Cocoa®, Cocoa Touch®, Objective-C®, and Swift™ by Marcel Weiher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8. Memory Example: FilterStreams

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required