Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARC with non-Foundation Objects

I have made my own Objective-C base class to use in Objective-C projects (without Foundation/Cocoa classes or API). While I don't mind writing my own retains and releases, it's a tedious process so I'm wondering if I can use ARC with my custom classes.

Specifically:

  • Is it possible to use ARC with custom classes?
  • Do my reference-counting selectors have to be called retain and release (and autorelease)?
  • What additional requirements are there to make ARC work as expected for custom classes (other than including the -fobjc-arc argument when compiling)?
like image 830
Ephemera Avatar asked Feb 24 '26 16:02

Ephemera


1 Answers

Is it possible to use ARC with custom classes?

Of course it is.

Do my reference-counting selectors have to be called retain and release (and autorelease)?

Yes, they do. Apple has hardcoded the method names of its favorite Objective-C library (Foundation) into the compiler. Damn bad programming pattern, isn't it?

What additional requirements are there to make ARC work as expected for custom classes (other than including the -fobjc-arc argument when compiling)?

As far as I know, nothing.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!