Objective-C class names with a +

有些话、适合烂在心里 提交于 2019-12-01 18:51:24

I think you are looking at the file names of Categories, not Classes. The plus character + is not allowed in class names or any other identifier in Objective-C.

An Objective-C category is a way of adding methods (but not instance variables) to a class you don't necessarily have the source to. For example, if you frequently want to make upside-down copies of UIImages, you can use a category to add a upsideDownImage method onto the UIImage class.

It's common to save this code in a file named UIImage+UpsideDown.m (with an accompanying header file, UIImage+UpsideDown.h).

This is a naming convention when using an Objective-C Category to extend the functionality of a class. See the article: http://macdevelopertips.com/objective-c/objective-c-categories.html for a much better explanation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!