You can get the maximum value in an NSSet full of NSNumbers using Key-Value-Coding like so:
NSSet *set = [NSSet setWithArray:@[ @1,@2,@3,@4,@5 ]]; NSNumber *maxValue = [set valueForKeyPath:@"@max.self"];
It took me ages to find the correct KVC syntax for this. Source is linked below, and has a bunch of other cool uses of KVC.
Key-value coding is one of my more favorite things about Cocoa (up there with
NSPredicate). Basically, it allows you to access properties of objects by name (ie, as a string) rather than invoking a method (er… sending a message)…
Hello, fellow code monkeys.
Look at your editor. Now back at mine. Now back at yours. Now back to mine. Sadly your editor is not like mine. But if you stopped using noob-scented editor, and switched to Sublime Text 2, your editor could look like mine.
Look down. Back up. Where are you?
You are on a desk with the editor your editor could look like.
What’s in your hand? Back at me. I have it! It’s a package control with several handy plugins that you would love. Look again. The plugins are now diamonds. Anything is possible when your editor looks like Sublime Text 2 and not Eclipse.
I’m on a horse.
阅读此文前，请先阅读我之前写的《Rails Is Not For Beginners》，当然最好也把文章里的那些链接也点一遍，把评论啥的也看一遍。
我非常同意 DHH 的观点，learnability（易学性） 和 usability（可用性） 是个两难的问题，Rails 优先考虑 usability 是完全正确的，至于 learnability 我个人觉得 rails 已经做得很不错了。
拿 Sinatra 和 Rails 比其实是件蛮搞笑的事情，相对 Rails 来说，Sinatra 充其量就是一个高级一点的玩具，拿来写个 Demo 有时都可能不够用，稍微复杂一点，就办不到了，或需要付出相当的时间和精力去搞定（当然有些场合 Sinatra 会比 Rails 更适合，这好像是废话 :)）。
针对国内环境，针对「Rails Is Not For Beginners」这个话题，我倒想展开来说几句。