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?

- 44,553
- 16
- 113
- 131

- 2,081
- 1
- 19
- 25
-
1Here's a heretical one: make it available on other platforms. – Avery Payne Jun 21 '09 at 02:50
12 Answers
Built-in regular expression support (a la RegexKit) would be extremely handy. NSRegularExpression is available on iOS 4.0+, but it is still not available on Mac OS X yet.
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 NSNumberFormatter to format US Telephone Numbers and Remove all but numbers from NSString.)
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.

- 1
- 1

- 44,553
- 16
- 113
- 131
-
2NSPredicate includes at least rudimentary regular expression support via the MATCHES expression. – Barry Wark Jun 20 '09 at 03:26
-
True. But http://regexkit.sourceforge.net/ goes a lot further, and something like that would be much more powerful and flexible. – Quinn Taylor Jun 21 '09 at 14:36
-
Since SO’s RSS just resurrected this… for your second point, I’d say: pervasive stream interfaces, with text and binary streams (and adapters between the two). And while I’m at it, strings whose interface is defined in terms of Unicode code points, not UTF-16 code elements. – Jens Ayton May 03 '10 at 23:42
A way to specify copy/retain properties that are automatically released in dealloc. Perhaps
@property (nonatomic, copy, dealloc) NSString* name;
And RegexKit of course.

- 17,664
- 2
- 43
- 56
Multi-user support for Core Data. One can dream :)
But at least Core Data is now available on the iPhone with OS 3.0.

- 34,177
- 3
- 81
- 112
-
1Why people keep asking for this is beyond me. Multi-user support would be a major design change and cause extra headaches for those using Core Data for its intended environment. But a separate frameworking for bridging Core Data to a multi-user server? Yes! – Mike Abdullah Jul 16 '09 at 10:47
-
Core Data is not a database. Asking for multi-user support in Core Data is the same as asking for multi-user support in XML. It’s just not something that makes sense. – Sven Sep 05 '10 at 13:30
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)

- 6,608
- 1
- 32
- 31
-
CoreData is technically a separate framework from AppKit and Foundation, and is developed by a different group than the guys, but is tied to Cocoa enough that one could consider this something missing from Cocoa ... in a way... :-) I'm not saying it wouldn't be cool to have, just wondering where it would need to be added. – Quinn Taylor Jun 23 '09 at 06:58
- Good regular expression support
- Layout managers in AppKit. Autoresizing just doesn't cut it for complicated GUIs.

- 23,305
- 6
- 62
- 80
-
What type of layout managers do you mean? Like the ones in Java? Examples would be nice to understand exactly what you're getting at. – Quinn Taylor Jun 21 '09 at 14:32
-
Yeah something similar to Java would do. Anything that would solve the problems expressed on http://katidev.com/blog/2008/02/12/why-i-say-no-to-autoresizing/ – Tom Dalling Jun 21 '09 at 22:45
-
1Regexes are starting to show up in iOS 4, so they'll probably be added to desktop in 10.7. As for a layout manager, check out this way to add constraints on `NSViews`: http://github.com/davedelong/CHLayoutManager – Dave DeLong Aug 22 '10 at 02:16
@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).

- 25,221
- 5
- 36
- 49
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.

- 9,796
- 9
- 51
- 71
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?
Definitely a counterpart for Carbon HotKeys!
-
1Well, that part of Carbon was updated to 64-bit, and there are a bunch of good Cocoa wrappers out there, like PTHotKey or my own DDHotKey: http://github.com/davedelong/DDHotKey – Dave DeLong Aug 22 '10 at 02:45