The garbage collector invokes this method on the receiver before disposing of the memory it uses.
ガベージコレクションは、このメソッドをレシバー上で、それが使うメモリの処分を行う前に発動します。
Availability
iOS 2.0–10.0 Deprecated
iPadOS 2.0–10.0 Deprecated
macOS 10.4–10.12 Deprecated
Mac Catalyst 13.0–13.0 Deprecated
tvOS 9.0–10.0 Deprecated
watchOS 2.0–3.0 Deprecated
Technology
Objective-C Runtime
Objective-Cランタイム
Declaration
宣言
funcfinalize()
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:
あなたはこのメソッドをオーバーライドして、レシーバが獲得しているリソースを放棄することができます、以下の例で示すように:
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.
An NSFileManager object sends this message to its handler for each error it encounters when copying, moving, removing, or linking files or directories.
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.