在 UML 类图上表示 Objective C 协议

发布于 2024-08-28 18:45:37 字数 555 浏览 2 评论 0原文

我应该如何在 UML 类图上正确引用协议?

例如,我的 ListViewController 符合 UITableViewDataSourceUITableViewDelegate 协议...我应该将 cellForRowAtIndexPath 或 <代码>numberOfRowsInSection 方法? ...在实现它们的 ListViewController 中或类似这样的地方:

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

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

如果我执行后者,那么 ListViewController 类和协议框之间的关联是什么?我所要展示的只是我如何融入 Cocoa Touch。

谢谢。

How should I correctly reference protocols on a UML class diagram?

For example my ListViewController conforms to the UITableViewDataSource and UITableViewDelegate protocols... where do I put the cellForRowAtIndexPath or numberOfRowsInSection methods? ... in ListViewController where they are implemented or in something like this:

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

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

If I did the latter what would be the association between the ListViewController class and the protocol box be? All I have to show is how I hook into Cocoa Touch some how.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风吹短裙飘 2024-09-04 18:45:37

协议在某种程度上相当于 java 中的接口,因此您可以找到 java UML 图并对其进行处理。

另外,来自 http://en.wikipedia.org/wiki/Class_diagram

在UML建模中,一个实现
关系是之间的关系
两个模型元素,其中一个模型
元素(客户端)实现了
其他模型元素的行为
(供应商)指定。一个
实现由虚线表示
带有未填充箭头的线
面向供应商

...

之间的实现关系
类与接口以及类与接口之间
组件和接口表明
类实现操作
由接口提供。

因此,如果我没看错的话,ListViewController 将有一条虚线,其中有一个指向 UITableViewDataSource 的未填充箭头。

Protocols are sort of equivalent to interfaces in java, so you can find a java UML diagram and work off that.

Also, from 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.

So if I'm reading that correctly, ListViewController would have a dashed line with an unfilled arrowhead pointing to UITableViewDataSource.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文