2

When using ARC I will sometimes mark individual files to not use ARC so I can use C struct's with object fields. Instead of doing this I have been thinking recently of declaring the struct object fields as __unsafe_retained and then using the objc_retain()/objc_release() functions to retain and release them, that way the rest of my class can use ARC and for library like classes all of the manual ARC can be hidden behind the scenes. Is there any reason not to do this, I have briefly tested it and it seems to work, the only issue is that I couldn't find the header files for objc_retain() and objc_release().

Nathan Day
  • 5,981
  • 2
  • 24
  • 40
  • It might work, but I don't think you can consider it "officially supported", so you can't count on it to keep working. If you need to make a data structure composed of ObjC objects, why not use ObjC? – rickster Dec 04 '12 at 05:42
  • I do use objects most of the time, but in some situation for memory or speed reason like having and array of struct I like to use structs, its usually when I am writing library classes. – Nathan Day Dec 04 '12 at 05:57

0 Answers0