开发者

Why is it bad design for a UITableViewCell to send messages to the controller in MVC design?

开发者 https://www.devze.com 2023-03-19 04:26 出处:网络
I\'m wondering what the reasoning is behind apple\'s decision not to have UITableViewCells know their row and section, even to the point where implementing a custom accessory button is seemingly non t

I'm wondering what the reasoning is behind apple's decision not to have UITableViewCells know their row and section, even to the point where implementing a custom accessory button is seemingly non trivial and tricky. I thought it was correct to have the controller receive messages from both sides and mediate per se, could anyone explain this? Or is it maybe just a feat开发者_Go百科ure they haven't gotten to yet?

Thanks.


Because it ties them to the controller. If the cellViews blindly do what they're told, a wide variety of controllers can re-use them. If they're sending specific messages to a controller, that cell can only be used by a controller that conforms to that protocol. It's not the end of the world if a view talks back, but it's just cleaner if the view is out there in la-la land, happy and oblivious.

0

精彩评论

暂无评论...
验证码 换一张
取 消