objective-c – 代表UML类图的Objective C Protocols

前端之家收集整理的这篇文章主要介绍了objective-c – 代表UML类图的Objective C Protocols前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我应该如何正确引用UML类图上的协议?

例如,我的ListViewController符合UITableViewDataSource和UITableViewDelegate协议……我在哪里放置cellForRowAtIndexPath或numberOfRowsInSection方法? …在ListViewController中实现它们或者像这样:

<<Protocol>>
    UITableViewDataSource 
    ---------------------

    ---------------------
    -numberOfRowsInSection

如果我做了后者,ListViewController类和协议盒之间的关联是什么?我必须展示的是我如何与Cocoa Touch挂钩.

谢谢.

解决方法

协议有点类似于java中的接口,所以你可以找到一个java UML图并解决它.

此外,从http://en.wikipedia.org/wiki/Class_diagram

In UML modeling,a realization
relationship is a relationship between
two model elements,in which one model
element (the client) realizes the
behavior that the other model element
(the supplier) specifies. A
realization is indicated by a dashed
line with an unfilled arrowhead
towards the supplier
.

A realization relationship between
classes and interfaces and between
components and interfaces shows that
the class realizes the operations
offered by the interface.

因此,如果我正确读取,ListViewController将有一个虚线,其中未填充的箭头指向UITableViewDataSource.

猜你在找的C&C++相关文章