Timeline for Rewrite code from Objective-C to conform with Swift power tools and concise style
Current License: CC BY-SA 3.0
        9 events
    
    | when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 11, 2015 at 16:50 | comment | added | Andrew Robinson | 
        
            
    @robmayoff, I like your code, with the exception of update() in MasterCell. You check for nil on model if (model != nil), then use optional chaining anyways. I would replace this with if let theModel = model and refer to theModel without chaining with ? or !.
        
     | 
|
| Sep 17, 2014 at 18:25 | comment | added | rob mayoff | Some people think the view shouldn't read the model directly. Some people think it should. I am in the latter group. I don't want “MVC” to stand for “Massive View Controller”. There's going to be custom code to adapt the app-specific model to generic views; whether that code should live in the controller, an app-specific custom view, or some other object is a matter of opinion, taste, and debate. | |
| Sep 17, 2014 at 6:20 | comment | added | Geoff Hackworth | Great answer, but passing the model to the master table view cell violates MVC. I would expose description and option properties with setters that set the textLabel and detailTextLabel titles. The MasterViewController then sets those properties. This keeps the knowledge of the model away from the view (the table cell). I'd go further and use a custom detail cell too with properties that the VC uses. That would hide the implementation details of using textLabel and accessory views from the VC. More code, but less coupling and better separation of concerns. | |
| Sep 15, 2014 at 19:34 | vote | accept | CommunityBot | ||
| Sep 15, 2014 at 19:34 | comment | added | user53113 | I'm speechless. Great explanation. Great Objective-C / Swift code. I even laughed reading your answer ("toy design", big lol). But now I have hope: we can do better code for even simple things. Thank you! | |
| Sep 15, 2014 at 18:16 | comment | added | rob mayoff | It isn't necessary. It is a vestige of an evolutionary dead end. | |
| Sep 15, 2014 at 18:05 | comment | added | Martin R | 
        
            
    Wow, what an answer! - One question though: I cannot see where the private class func toUnsafeMutablePointer is used, and your code seems to work without it. Is that really needed?
        
     | 
|
| Sep 15, 2014 at 17:24 | review | First posts | |||
| Sep 15, 2014 at 17:47 | |||||
| Sep 15, 2014 at 17:21 | history | answered | rob mayoff | CC BY-SA 3.0 |