I have a header file (C Like)
And I have to make an Obj-c library (or just couple of .m -s) that implements it.
Whoever will call the library will be a C program.
However I don't want to manually deal with memory allocations and I want to use ARC.
May I use autoreleasepool{}
inside my functions in order to have ARC working and functioning...
Or I have to go back in couple years/uninstall my laziness and do this manually ?
May I use autoreleasepool{} inside my functions in order to have ARC working and functioning...
@autoreleasepool
is not only for ARC. You can use @autoreleasepool
with both -fobjc-arc
and -fno-objc-arc
.
http://clang.llvm.org/docs/AutomaticReferenceCounting.html#autoreleasepool
@autoreleasepool may be used in non-ARC translation units, with equivalent semantics.
Besides,
Whoever will call the library will be a C program.
EDITED
You mean the application program is written in C language and the library program is written in Objective-C language? In that case, you should use @autoreleasepool
in your code. Usually, for OS X Cocoa application, there is a runloop that has Autorelease Pool, so no need to have @autoreleasepool
in your code till some certain situation (for example, avoiding huge amount of memory usage).
EDITED
Anyway, you can use ARC in your library code, but it should be compiled with -fobjc-arc
option.