Difference between revisions of "Using ARC in tweaks"

From iPhone Development Wiki
Jump to: navigation, search
(this was straight up misinformed and incorrect....)
(How should I use ARC in tweaks?)
Line 8: Line 8:
  
  
It is not recommended that you use ARC in any "hooks", unless if you absolutely know what you are doing. Hook methods are very much different from your typical Objective-C class declarations, as the compiler has no concept of ownership. Every hook is a compiled as a static C function, and only in very specific cases ARC will behave as you'd expect it to be.
+
It is not recommended that you use ARC in any "hooks", unless if you absolutely know what you are doing. Hook methods are very much different from your typical Objective-C class declarations, as the compiler has no concept of ownership. Every hook is a compiled as a static C function, and only in very specific cases ARC will behave as you'd expect it to.
  
 
However, if you are declaring new classes, or subclassing existing ones (not hooking), then ARC will behave exactly as one would expect it to behave.
 
However, if you are declaring new classes, or subclassing existing ones (not hooking), then ARC will behave exactly as one would expect it to behave.

Revision as of 11:52, 25 January 2015

What is ARC?

In Objective-C and Swift programming, Automatic Reference Counting (ARC) is a memory management enhancement where the burden of keeping track of an object's reference count is lifted from the programmer to the compiler. In traditional Objective-C, the programmer would send retain and release messages to objects in order to mark objects for deallocation or to prevent deallocation. Under ARC, the compiler does this automatically by examining the source code and then adding the retain and release messages in the compiled code.

How should I use ARC in tweaks?

It is not recommended that you use ARC in any "hooks", unless if you absolutely know what you are doing. Hook methods are very much different from your typical Objective-C class declarations, as the compiler has no concept of ownership. Every hook is a compiled as a static C function, and only in very specific cases ARC will behave as you'd expect it to.

However, if you are declaring new classes, or subclassing existing ones (not hooking), then ARC will behave exactly as one would expect it to behave.