views:

641

answers:

12

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?

+1  A: 

Proper support for web services.

diciu
+13  A: 
  • 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.

Quinn Taylor
NSPredicate includes at least rudimentary regular expression support via the MATCHES expression.
Barry Wark
True. But http://regexkit.sourceforge.net/ goes a lot further, and something like that would be much more powerful and flexible.
Quinn Taylor
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.
Ahruman
+4  A: 

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

weichsel
Why 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
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
A: 

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?

+3  A: 

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)

Matt Ball
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
+2  A: 
  • Good regular expression support
  • Layout managers in AppKit. Autoresizing just doesn't cut it for complicated GUIs.
Tom Dalling
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
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
Regexes 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
+5  A: 

A way to specify copy/retain properties that are automatically released in dealloc. Perhaps

@property (nonatomic, copy, dealloc) NSString* name;

And RegexKit of course.

Peter N Lewis
That would be more of an Objective-C thing than a Cocoa thing.
dreamlax
+2  A: 

@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).

Diederik Hoogenboom
A: 

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.

marshall
A: 

Built-in JSON support for imports/exports.

Dave Gallagher
+1  A: 

A more friendly wrapper around the Keychain Services.

Justin Voss
A: 

Definitely a counterpart for Carbon HotKeys!

Erik Aigner
Well, 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