在Objective-C实现文件中的方法名称后面的分号 [英] Semicolon after the method name in Objective-C implementation file

查看:94
本文介绍了在Objective-C实现文件中的方法名称后面的分号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

- (void) designImageViewNow; {

//some code here

}

在实现文件objective-c中的主体括号之前的方法名称之后写分号; 是否正确。

Is it correct to write semicolon ; just after the method name before body brackets in the implementation file objective-c.

这会有用吗?

当我正在开发iPhone应用程序时,我错误地将方法名称后面的分号放在我的一个自定义类中。但没有任何警告或任何崩溃。事实上它工作正常。

As I am working on an iPhone app, I put the semicolon after the method name in one of my custom class by mistakenly. But there was no warning or any crash. In fact it is working fine.

推荐答案

是的,这样做是可以接受的语法。

Yes, it is acceptable syntax to do this.

事实上,我总是在我的实现中这样做,因为从接口到实现复制和粘贴方法定义是很容易的,反之亦然,而不必记住在哪里你是。这也有助于我在单独的行上使用对齐的括号。

In fact, I always do this in my implementations, because it then is trivial to copy and paste a method definition from interface to implementation and vice versa without having to remember where you are. It helps that I use aligned brackets on separate lines, as well.

Wil Shipley 就此与我达成一致

Wil Shipley agrees with me on this:


结束使用
分号的
方法实现上的定义行,这样你就可以将
它们复制到或从你的标题中复制(或者顶部的
私有类别)您的
文件)在他们更改时根据需要。

界面部分中需要分号,但不要在实施
部分中损坏

End the definition lines on your method implementations with a semicolon, so you can copy-n-paste them to or from your header (or the "Private" category at the top of your file) as needed when they change. Semicolons are required in the "interface" section, but don't hurt anything in the "implementation" section.

这篇关于在Objective-C实现文件中的方法名称后面的分号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆