本文介绍了@interface和@implementation指令中括号内的文字是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于Apple的一些示例代码的基本问题。在.m文件中,类声明如下所示:

I've got a very basic question about some sample code from Apple. In the .m file, the class declarations look like this:

@interface MyMovieViewController (OverlayView)
[...]
@end

@interface MyMovieViewController (ViewController)
[...]
@end

@implementation MyMovieViewController(ViewController)
[...]
@end

@implementation MyMovieViewController (OverlayView)
[...]
@end

@implementation MyMovieViewController
[...]
@end

完整代码。

似乎括号内的内容(OverlayView和ViewController)只是帮助分解代码并使其更具可读性,但实际上并不影响执行码。但我不想误解一些重要的东西,所以我想我会检查以确保。

It seems like the stuff inside parentheses ("OverlayView" and "ViewController") are just there to help break up the code and make it more readable, but don't actually impact the execution of the code. But I don't want to be misunderstanding something important, so I thought I'd check to make sure.

我的理解是否正确?谢谢!

Is my understanding right? Thanks!

推荐答案

这些被称为 Categories 并允许您进一步添加您的类的功能。

Those are called Categories and allow you to add further functionality to your classes.

这篇关于@interface和@implementation指令中括号内的文字是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 18:26