Next Page > Hide TOC

NSMutableCopying Protocol Reference

Adopted by
Various Cocoa classes
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in Mac OS X v10.0 and later.
Companion guide
Declared in
NSObject.h

Overview

The NSMutableCopying protocol declares a method for providing mutable copies of an object. Only classes that define an “immutable vs. mutable” distinction should adopt this protocol. Classes that don’t define such a distinction should adopt NSCopying instead.

NSMutableCopying declares one method, mutableCopyWithZone:, but mutable copying is commonly invoked with the convenience method mutableCopy. The mutableCopy method is defined for all NSObjects and simply invokes mutableCopyWithZone: with the default zone.

If a subclass inherits NSMutableCopying from its superclass and declares additional instance variables, the subclass has to override mutableCopyWithZone: to properly handle its own instance variables, invoking the superclass’s implementation first.

Tasks

Copying

Instance Methods

mutableCopyWithZone:

Returns a new instance that’s a mutable copy of the receiver.

- (id)mutableCopyWithZone:(NSZone *)zone

Parameters
zone

The zone from which memory is allocated for the new instance. If zone is NULL, the new instance is allocated from the default zone, which is returned by NSDefaultMallocZone.

Discussion

The returned object is implicitly retained by the sender, which is responsible for releasing it. The copy returned is mutable whether the original is mutable or not.

Availability
See Also
Declared In
NSObject.h

Next Page > Hide TOC


© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.