可可缺少什么? [英] What's missing in Cocoa?

查看:14
本文介绍了可可缺少什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您可以在 Cocoa 中添加任何东西,您会添加什么?您会说 Cocoa 中缺少任何主要或次要功能吗?也许由于框架中的遗漏,您不得不一遍又一遍地发明一个轮子?

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?

推荐答案

  • 内置正则表达式支持(a la RegexKit)将 方便.NSRegularExpression 在 iOS 4.0+ 上可用,但在 Mac OS X 上仍然不可用.

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

      一种从大型文本文件中逐步读取 NSString 对象的简单方法,而无需将整个内容加载到内存中.(NSInputStream 和 NSFileHandle 只是不符合这一点.)

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

      能够选择性地使 NSSet/NSMutableSet/NSCountedSet 按排序顺序存储和枚举对象(如 二叉搜索树) 肯定会受到欢迎.Cocoa 数组也是如此——目前我必须调用类似 -[NSArray sortedArrayUsingSelector:]-[NSMutableArray sortUsingSelector:] 之类的东西来获得一个排序的数组,对于集合我必须先创建数组.

      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.

      堆/优先级队列.CFBinaryHeap 的 Cocoa 包装器(绝对不像可可系列)可能会起作用.

      A heap / priority queue. A Cocoa wrapper around CFBinaryHeap (which is definitely not as easy to use as Cocoa collections) would probably work.

      可以为每个键存储多个值的字典,通常称为multiset.NSCountedSet 几乎是一个多重集/包,对于键值关联(NSMultiDictionary?)使用相同的东西会很好,而不必自己滚动.

      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.

      FSEvents 的友好包装器.(CFFileDescriptor 做了一些工作,但它不是 Cocoa-easy.)

      A friendly wrapper for FSEvents. (CFFileDescriptor does some of the work, but it's not Cocoa-easy.)

      一种从格式字符串和对象数组(不仅仅是可变参数)创建 NSString 的方法.此 SO 答案 显示了一个示例.让它与原语一起工作会很棘手......也许是一个 NSPointerArray?

      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?

      一致的集中式 API,可简化各种语言环境的电话号码格式(和解析).目前,您必须使用 NSNumberFormatter(或 NSScanner)自行推出,并且该过程繁琐且容易出错.(例如,请参阅 NSNumberFormatter 以格式化美国电话号码从 NSString 中删除除数字之外的所有内容.)

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

      当然,我绝对喜欢各种各样的数据结构总的来说,虽然与某些语言相比,Cocoa 的简单性令人耳目一新.

      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.

      这篇关于可可缺少什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆