If you could add anything to Cocoa, what would it be? Are there any features, major or minor, that you would say are missing in Cocoa. Perhaps there is a wheel you have had to invent over and over because of an omission in the frameworks?
Built-in regular expression support (a la RegexKit) would be extremely handy.
An easy way to progressively read NSString objects from a large text file without loading the entire thing into memory. (NSInputStream and NSFileHandle just don't measure up for that.)
The ability to optionally make NSSet/NSMutableSet/NSCountedSet store and enumerate objects in sorted order (like a binary search tree) would certainly be welcome. Same goes for Cocoa arrays — currently I have to call something like
-[NSArray sortedArrayUsingSelector:]
or-[NSMutableArray sortUsingSelector:]
to get a sorted array, and for sets I have to create the array first.A heap / priority queue. A Cocoa wrapper around CFBinaryHeap (which is definitely not as easy to use as Cocoa collections) would probably work.
A dictionary that can store multiple values for each key, commonly known as a multiset. NSCountedSet is pretty much a multiset/bag, and it would be nice to have the same for key-value associations (NSMultiDictionary?) instead of having to roll my own.
A friendly wrapper for FSEvents. (CFFileDescriptor does some of the work, but it's not Cocoa-easy.)
A method for creating an NSString from a format string and an array of objects (not just varargs). This SO answer shows an example. Getting it to work with primitives would be tricky... Maybe an NSPointerArray?
Consistent, centralized APIs that simplify formatting (and parsing) phone numbers for a variety of locales. Currently you have to roll your own with an NSNumberFormatter (or NSScanner), and the process is tedious and error-prone. (For example, see http://stackoverflow.com/questions/665111/ and http://stackoverflow.com/questions/1129521/.)
Of course, I'm definitely a fan of a wide variety of data structures in general, although Cocoa's simplicity is refreshing compared with some languages.
Multi-user support for Core Data. One can dream :)
But at least Core Data is now available on the iPhone with OS 3.0.
Certainly a reasonable interface from manage object contexts to SQL database servers'd be pretty cool.
I'd like to see better examples of writing custom views with programatically created cells, all autoscrolling nicely.
Also, there seems to be a real gap in IB's support for complex multi-paned windows with working splitters. I suppose they're working on this?
And whatever happened to resolution independence, huh?
A way to flag entire Core Data entities as transient. This would be particularly useful for implementing Bonjour sharing.
For example, let's say I've got an iTunes-like model, with Playlist
and Song
entities. Currently, to implement Bonjour sharing, I create two additional NSObject
subclasses, TransientPlaylist
and TransientSong
, which implement all of the same methods as their Core Data counterparts.
I shouldn't need to double the number of model classes just to have transient versions of my objects – not when I want them to behave exactly the same, sans persistence.
(Yes, the other option is to have an in-memory persistent store which houses all of the entities you want to be transient. Either way, it's unnecessary overhead)
- Good regular expression support
- Layout managers in AppKit. Autoresizing just doesn't cut it for complicated GUIs.
A way to specify copy/retain properties that are automatically released in dealloc. Perhaps
@property (nonatomic, copy, dealloc) NSString* name;
And RegexKit of course.
@property (..,copy)
support for mutable type classes (NSMutableArray
, NSMutableDictionary
, etc.). Currently, if you assign a value to property for a mutable type class the object created will be non-mutable (due to the copy).
Coming into Cocoa from the .NET world I have one request: LINQ!
Over the last few months I have grown to love being able to use LINQ on any collection that comes near me.