Instance Method

finalize()

The garbage collector invokes this method on the receiver before disposing of the memory it uses.

Declaration

func finalize()

Discussion

The garbage collector invokes this method on the receiver before disposing of the memory it uses. When garbage collection is enabled, this method is invoked instead of dealloc.

You can override this method to relinquish resources the receiver has obtained, as shown in the following example:

- (void)finalize {
    if (log_file != NULL) {
        fclose(log_file);
        log_file = NULL;
    }
    [super finalize];
}

Typically, however, you are encouraged to relinquish resources prior to finalization if at all possible. For more details, see Implementing a finalize Method.

Special Considerations

It is an error to store self into a new or existing live object (colloquially known as “resurrection”), which implies that this method will be called only once. However, the receiver may be messaged after finalization by other objects also being finalized at this time, so your override should guard against future use of resources that have been reclaimed, as shown by the log_file = NULL statement in the example. The finalize method itself will never be invoked more than once for a given object.

See Also

Deprecated Methods

func accessibilityAttributeNames() -> [NSAccessibility.Attribute]

Returns an array of attribute names supported by the receiver.

Deprecated
func accessibilityAttributeValue(NSAccessibility.Attribute) -> Any?

Returns the value of the specified attribute in the receiver.

Deprecated
func accessibilityAttributeValue(NSAccessibility.ParameterizedAttribute, forParameter: Any?) -> Any?

Returns the value of the receiver's parameterized attribute corresponding to the specified attribute name and parameter.

Deprecated
func accessibilityActionDescription(NSAccessibility.Action) -> String?

Returns a localized description of the specified action.

Deprecated
func accessibilityActionNames() -> [NSAccessibility.Action]

Returns an array of action names supported by the accessibility element.

Deprecated
func accessibilityArrayAttributeCount(NSAccessibility.Attribute) -> Int

Returns the count of the specified accessibility array attribute.

func accessibilityIndex(ofChild: Any) -> Int

Returns the index of the specified accessibility child in the parent.

func accessibilityIsAttributeSettable(NSAccessibility.Attribute) -> Bool

Returns a Boolean value that indicates whether the value for the specified attribute in the receiver can be set.

Deprecated
func accessibilityIsIgnored() -> Bool

Returns a Boolean value indicating whether the receiver should be ignored in the parent-child accessibility hierarchy.

Deprecated
func accessibilityParameterizedAttributeNames() -> [NSAccessibility.ParameterizedAttribute]

Returns a list of parameterized attribute names supported by the receiver.

Deprecated
func accessibilityPerformAction(NSAccessibility.Action)

Performs the action associated with the specified action.

Deprecated
func accessibilitySetOverrideValue(Any?, forAttribute: NSAccessibility.Attribute) -> Bool

Overrides the specified attribute in the receiver or adds it if it does not exist, and sets its value to the specified value.

Deprecated
func accessibilitySetValue(Any?, forAttribute: NSAccessibility.Attribute)

Sets the value of the specified attribute in the receiver to the specified value.

Deprecated
func fileManager(FileManager, shouldProceedAfterError: [AnyHashable : Any]) -> Bool

An NSFileManager object sends this message to its handler for each error it encounters when copying, moving, removing, or linking files or directories.

Deprecated
func fileManager(FileManager, willProcessPath: String)

An NSFileManager object sends this message to a handler immediately before attempting to move, copy, rename, or delete, or before attempting to link to a given path.

Deprecated
func fontManager(Any, willIncludeFont: String) -> Bool

Requests permission from the Font panel delegate to display the given font name in the Font panel.

Deprecated
func namesOfPromisedFilesDropped(atDestination: URL) -> [String]?

Returns the names of the files that the receiver promises to create at a specified location.

Deprecated
func workflowController(AMWorkflowController, didError: Error)

Invoked when the receiver's workflow encounters an error.

Deprecated
func workflowController(AMWorkflowController, didRun: AMAction)

Invoked when an action in the receiver's workflow is finished running.

Deprecated
func workflowController(AMWorkflowController, willRun: AMAction)

Invoked when an action in the receiver's workflow is about to run.

Deprecated
func workflowControllerDidRun(AMWorkflowController)

Tells the delegate that the workflow controller object finished running.

Deprecated
func workflowControllerDidStop(AMWorkflowController)

Tells the delegate that the workflow controller object has stopped.

Deprecated
func workflowControllerWillRun(AMWorkflowController)

Tells the delegate that the workflow controller object is about to run.

Deprecated
func workflowControllerWillStop(AMWorkflowController)

Tells the delegate that the workflow controller object is about to stop.

Deprecated