Protocol: NSDiscardableContent

Overview

You implement this protocol when a class’s objects have subcomponents that can be discarded when not being used, thereby giving an application a smaller memory footprint.Returns a Boolean value indicating whether the discardable contents are still available and have been successfully accessed. (required)Called to discard the contents of the receiver if the value of the accessed counter is 0. (required)Called if the discardable contents are no longer being accessed. (required)Returns a Boolean value indicating whether the content has been discarded. (required)

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) beginContentAccess

Returns a Boolean value indicating whether the discardable contents are still available and have been successfully accessed. (required) Call this method if the object’s memory is needed or is about to be used. This method increments the counter variable, thus protecting the object’s memory from possibly being discarded. The implementing class may decide that this method will try to recreate the contents if they have been discarded and return YES if the re-creation was successful. Implementors of this protocol should raise exceptions if the NSDiscardableContent objects are used when the beginContentAccess method has not been called on them.

Returns:

  • (Boolean)

    YES if the discardable contents are still available and have now been successfully accessed; otherwise, NO.

- (Object) discardContentIfPossible

Called to discard the contents of the receiver if the value of the accessed counter is 0. (required) This method should only discard the contents of the object if the value of the accessed counter is 0. Otherwise, it should do nothing.

Returns:

- (Object) endContentAccess

Called if the discardable contents are no longer being accessed. (required) This method decrements the counter variable of the object, which will usually bring the value of the counter variable back down to 0, which allows the discardable contents of the object to be thrown away if necessary.

Returns:

- (Boolean) isContentDiscarded

Returns a Boolean value indicating whether the content has been discarded. (required)

Returns:

  • (Boolean)

    YES if the content has been discarded; otherwise, NO.