In the Cocoa world, the big news from WWDC is the advent of Automatic Reference Counting, or ARC. The only real documentation for the system is an unlinked reference page on the Clang website, but as Clang is open source and the implementation’s in the latest builds now, that counts as public information.
The Cocoa frameworks have long used a reference-count-based system, but as of Mac OS X v10.5, Apple added optional garbage collection. As with most GC systems, you can mark certain references as
__weak (which automatically become
nil when their target is collected), and the actual collection of…
Why did I miss last week’s post? To test this!
A few posts back I suggested the use of a category’s
+load method as a way to safely swizzle methods in a plugin. What do you do, though, if the same category is going to be loaded twice?
The established behavior of categories, of course is that the last one loaded “wins”.
The behavior of classes, however, is that the first one loaded wins.
That is, if a bundle defines a class with the same name as an existing class, it is not loaded.
[bundle principalClass] returns the existing…
If you’re a Cocoa plugin writer, sanctioned or otherwise, you’ve probably thought about categories. About how you can magically add methods to existing classes…and if you’re careful, you can replace existing methods as well. With a few caveats: you can’t call the original method, and if someone else is doing the same thing, only one of you will win. Which makes it a bad idea, at best.
Well, today I was absentmindedly reading through GCC extensions to the C languages, and came across this tidbit:
+load is a method that is not overridden by categories. If a class…