Deep Copying (Bug Fix)

A few months ago I wrote a short piece on creating deep mutable copies of plist data structures. Today, a (modestly anonymous) reader was kind enough to write in with a bug fix, which I would like to share with you.

NSNull

Briefly, the problem was that my code contained no provision for handling NSNull objects, which represent nil values in collections. The reader provided the following code to fill this gap:

@interface NSNull (DeepMutableCopy)

- (id)deepMutableCopy;

@end

@implementation NSNull (DeepMutableCopy)

- (id)deepMutableCopy
{
    return self;
}

@end

(Note that NSNull is a singleton.)

Code

You can download complete, updated header and implementation files, if you’d like. Thanks for reading.

Share and Enjoy:
  • Twitter
  • Facebook
  • Digg
  • Reddit
  • HackerNews
  • del.icio.us
  • Google Bookmarks
  • Slashdot
This entry was posted in iPhone. Bookmark the permalink.

Comments are closed.