为什么一些Objective-C文件名的名称中有减号或加号 [英] Why do some Objective-C file names have a minus or plus sign in their name

查看:674
本文介绍了为什么一些Objective-C文件名的名称中有减号或加号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我要添加到我的项目的库中,有一个名为NSString-Base64Extensions.h(带有NSString-Base64Extensions.m)和一个叫NSString + PECrypt.h(带有NSString + PECrypt.m)的文件。 / p>

这是什么意思?

解决方案

文件,其中包含现有类的类别



你可以期望NSString + PECrypt.m包含一个类别,它添加到 NSString 的方法。同样,NSString-Base64Extensions是 NSString 上的类别方法。



类别是一种将方法添加到现有类在Objective-C中,没有子类化,将在此处中详细讨论。


In a library I want to add to my project, there is a file called NSString-Base64Extensions.h (with NSString-Base64Extensions.m) and one called NSString+PECrypt.h (with NSString+PECrypt.m).

What does this signify?

解决方案

That is the convention for naming files, that contain categories for existing classes. The - and + sign are just different ways of expressing that, no difference other than style.

You can expect NSString+PECrypt.m to contain a Category that adds to the methods of NSString. Likewise, NSString-Base64Extensions are Category methods on NSString.

Categories are a way of adding methods to an existing class in Objective-C, without subclassing, it is discussed in more detail here.

这篇关于为什么一些Objective-C文件名的名称中有减号或加号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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