News for hackers. Stuff that matters.
Re:OS X Auditor by chc on Sunday September 14, 2014 @03:37PM (#8316019)
Chaining itself isn't really the problem here IMO. Creating a variable for each level of the nested data structure and manually checking for the validity of each subsequent one would really, really not produce more readable code. It would turn a "get this value out of a data structure" expression into about 15 lines of code that each need to be individually read and understood. The problem is that Cocoa doesn't provide a great way to say "Access this stuff in this data structure unless it isn't there."

An option type is really the best way to kill this breed of problem, and thankfully Apple is including one in Swift, though it's still somewhat green.

Re:OS X Auditor by photojosh on Sunday September 14, 2014 @08:13PM (#8316707)
That's a Obj-C problem, because it's being fixed with what Swift does with it's '?' on variables. :)
Re:OS X Auditor by chc on Monday September 15, 2014 @01:25PM (#8320082)
Not exactly. This program would have the same problem in Swift, because rather than returning optionals, Swift arrays have the same explode-on-invalid-accesses behavior as NSArray.