Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's missing in Cocoa? [closed]

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?

like image 287
Bridger Maxwell Avatar asked Jun 19 '09 18:06

Bridger Maxwell


5 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.

like image 112
12 revs, 2 users 93% Avatar answered Nov 03 '22 19:11

12 revs, 2 users 93%


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

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

And RegexKit of course.

like image 23
Peter N Lewis Avatar answered Nov 03 '22 19:11

Peter N Lewis


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

like image 4
Thomas Zoechling Avatar answered Nov 03 '22 20:11

Thomas Zoechling


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)

like image 3
Matt Ball Avatar answered Nov 03 '22 19:11

Matt Ball


A more friendly wrapper around the Keychain Services.

like image 3
Justin Voss Avatar answered Nov 03 '22 20:11

Justin Voss