Mixing garbage collection with normal code

I know my way around Objective-C, and I have experience with garbage collection from .NET, although I have never used it in objective-c. I write my code without using it.

Now I'm thinking of using one of the Blocks frameworks, available only for GC. My question is: can I use the framework without any changes in my current code without GC and without using GC?

+3
source share
3 answers

The process is either a GC or not a GC. That is, all Objective-Cs will either always be GC'd or they will never be GC'd. In one process, mixing of two memory models does not occur. You cannot combine a GC structure only with a frame that does not contain a GC.

When creating the framework, you can configure the GC to be “supported,” at which point the frame can be used in both GC'd and in a process other than GC. However, you will need to maintain correctness for both work environments separately.

What is the Blocks structure you are referring to? If you're talking about blocks, the language feature comes in Snow Leopard Objective-C, then it works great with both GC and non-GC.

+3
source

, ", GC , , Cocoa / , ."

, . , . , . ( , .)

+3

GC ( ), . GC, , / GC

GC, .

: : GC (-fobjc-gc-only), / . GC, GC. , GC (-fobjc-gc), / , GC.

EDIT: ( ): GC-only, -fobjc-gc -fobjc-gc-only , , / . , -fobjc-gc-only , GC, . , -fobjc-gc, GC-, GC. , :

, GC , / .

, , -, -fobjc-gc -fobjc-gc-only.

-, . :

-fobjc-gc-only , GC-. , GC , Cocoa / , .

, GC Required, , GC.

:

-fobjc-gc , GC, /. GC / .

Thus, while the burden is for the developer to include the save / release logic in the project that was compiled by GC Supported, this allows the frame to be loaded in any application.

I apologize for yesterday's obscure sunrise. I worked for 3 hours of sleep and tried to do several things at once. There was never a good idea.

0
source

Source: https://habr.com/ru/post/1737580/


All Articles