I made a static library that was coded using ARC. I plan to distribute this library for other people to use. I understand that nothing needs to be done to include an ARC static library in a non-ARC project, but what about including ARC header files? For example, the headers for my ARC static library declare properties as weak and strong but when I try to include these headers in a non-ARC project, the compiler freaks out.
Any ideas?
For
strong, you can just useretain. They’re identical.weakis trickier, and while I know several ways that should work, I’m not certain the best way to handle it.First, make sure you actually need it. If you’re supporting iOS4, you can’t have
weakanyway, so the issue is moot. My gut feeling is that I’d probably just avoidweakand make all these problems go away. weak is nice, but it’s not that big a deal to avoid in most cases.That said, there are some approaches that will work. The best is probably to declare
weakaccessors without properties in the header. Instead of this:Do this:
Then you can still declare a
weakproperty inside your implementation file. The caller can still use dot notation for this, BTW.It’s possible that you’ll get a compile error here, since
setDelegate:technically takes a__strong id. If that’s the case, just hand-implementsetDelegate:Haven’t tested it, but that should work. You might also declare the ivar
_delegateto be__weakin the@implementationblock rather than declaring it as aweakproperty.Like I said; I haven’t tested any of this out. Please post your findings if it works.