3 ms·
UIKit is designed to be built upon. A lot of Apple stuff may be a black box but it is designed to be subclassed. This is really an all or nothing affair. Either
by reidmain 14y ago
UIKit is designed to be built upon. A lot of Apple stuff may be a black box but it is designed to be subclassed. This is really an all or nothing affair. Either this works perfectly for you or you are shit out of luck and you have to compromise to fit inside their box.
- Zev 14y agoA lot of Apple stuff may be a black box but it is designed to be subclassed. Aside from a small number of top-level classes[1] UIKit isn't designed to be subclassed. When you subclass things like UIAlertView, UIButton, UISwitch, UITextField, UIWebView… etc, you're in for a world undocumented gotchas and spending hours to do small simple things. 1. UIView, UIControl, UITableViewCell, UIScrollView, UIGestureRecognizer, UIViewController, UIApplication and maybe one or two other classes.
- reidmain 14y agoAnd you've listed about 90% of the things I usual end up subclassing because I've hit some limitation. Also I wasn't talking specifically about UIKit. Foundation is another great framework that I've subclassed many times. It's not perfect but Apple puts a lot of work into documenting how to subclass their frameworks. Third-party UI frameworks like this are much less forgiving.
- Zev 14y agoCan you give an example of some things that you subclass?
- reidmain 14y agoFrom Foundation? NSDictionary, NSArray and NSOperation instantly jump to mind.
- Zev 14y agoWhat do you get out of subclassing NSDictionary or NSArray that you don't get out of a category?
- reidmain 14y agoWell in this case I subclassed them so I could have the backing data source only weakly reference the items in the dictionary/array and because I subclassed them I can use them wherever NSDictionary or NSArray is an accepted parameter. Apple's documentation also gives some examples: https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html#//apple_ref/doc/uid/20000137-740795 https://developer.apple.com/library/ios/#documentation/Cocoa... https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/Reference/Reference.html#//apple_ref/doc/uid/20000140-DontLinkElementID_1 https://developer.apple.com/library/ios/#documentation/Cocoa...