October 2010
3 posts
1 tag
Method Swizzling
Recently I wrote about how to dynamically subclass objects in Objective-C, and when that might be useful. While dynamic subclassing can be really useful, there is one major gotcha that can make it not very effective, and that was hinted at the end of my post: Key-Value Observing. When you add an observer to an object, the KVO mechanism will dynamically subclass that object to implement the...
Oct 24th
4 notes
1 tag
Dynamic Subclassing
If you’ve seen my github.com page or my portfolio link, you’re probably aware of a project of mine called CHLayoutManager. CHLayoutManager, for those of you not in-the-know, is a way to define the layout of a user interface on the Mac via constraints (as opposed to autoresizing masks). For example, if you have two buttons “A” and “B”, you can say “I want...
Oct 8th
4 notes
1 tag
Drawing a gradient-filled rounded rect with a drop...
This is something I’ve been fiddling with for the past few hours trying to get to work right. I tried doing stuff with CoreGraphics, drawing paths, drawing images, and so on, but it never quite worked correctly. Then I stumbled upon this post over at cimgf.com, which helped me figure it out. In a custom UIView subclass, I have this: - (void) awakeFromNib { //turning off bounds...
Oct 5th
4 notes