English 中文(简体)
名称相同的目标类别C
原标题:Objective-C categories with the same name

我有一套数据类别,我想以我自己的方法,通过创造每个类别独有的类别来扩大。

在宣布某一类别时,每个类别都需要有独一无二的名称,或者我可以重新使用同一名称。

例。 Saye 我有一个名单类别和清单类别,我希望这两个类别都有。 我现在宣布:

In List+Additions.h

@interface List (Additions) ...

In ListItem+Addtions.h

@interface ListItem (Additions) ...

这难道吗? 我可以说,它是否一贯工作。 哪一个类别的名称? 它是“补充”,还是“ListItem+Additions”。

最佳回答

类别名称为<代码>List (Additions)和ListItem(Additions)。 因此,这两个类别是单独和独立的。

Something like "ListItem+Additions" is a common convention for the file names which define the categories, but neither the compiler nor the runtime pay any attention to that.

问题回答

这难道吗? 我可以说,它是否一贯工作。 哪一个类别的名称? 它是“补充”,还是“ListItem+Additions”。

是的,它是ok的。

这两种类别都有相同的名称:Additions,但其中一类为Lists,另一类为。 ListItem s category. 因此,姓名没有冲突。 即使你将这两类声明放在同一档案中,情况也是如此。





相关问题
Asynchronous request to the server from background thread

I ve got the problem when I tried to do asynchronous requests to server from background thread. I ve never got results of those requests. Simple example which shows the problem: @protocol ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

iPhone numberpad with decimal point

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values ...

热门标签