| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
If you make immutable copies of immutable NSString, NSDate, NSArray or NSDictionary objects (to pick a few important examples) you simply get the same object with the reference count incremented. This saves some data copying for simple objects and by the time you get to complex objects like dictionaries the cost of copying can get pretty high.
A question I've had is when a container is said to be immutable, is it still fair game to change the contents of the objects that are contained?
For example: An NSArray containing NSMutableString objects, or an NSData object. Can you / Should you change the contents of the NSMutableStrings in the NSArray or the Memory block pointed to by the NSData?
Should items contained in immultable container classes be considered immutable?
P.S. Sorry for taking this further off-topic. As far as the OP goes, the main effeciency point I've seen when dealing with mutable Vs. immutable is that a copy of an immutable object can just be a reference to the same object, but a mutable copy needs to be a full copy. Things is, why do you need a copy? If it's to change it, then it needs to be mutable, and you need a full copy. If it's just to call it by a different name, then regardless of wether it's a mutable object or not you just need to pass a reference around.
| References: | |
| >Copy and release (From: Nicko van Someren <email@hidden>) | |
| >Re: Copy and release (From: Evan Schoenberg <email@hidden>) | |
| >Re: Copy and release (From: Nicko van Someren <email@hidden>) | |
| >Re: Copy and release (From: Paul Sargent <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.