Objective-C equivalent of Java packages?

后端 未结 6 1187
青春惊慌失措
青春惊慌失措 2021-02-07 11:35

What is the Objective-C equivalent of Java packages? How do you group and organize your classes in Objective-C?

6条回答
  •  无人共我
    2021-02-07 12:18

    What about something like this (inside a directory)?

     #define PruebaPaquete ar_com_oxenstudio_paq1_PruebaPaquete
    @interface ar_com_oxenstudio_paq1_PruebaPaquete : NSObject {
    

    and importing it like this:

     #import "ar/com/oxenstudio/paq1/PruebaPaquete.h"
     PruebaPaquete *p = [[PruebaPaquete alloc] init];
    

    and when you have name collision:

     #import "ar/com/oxenstudio/paq1/PruebaPaquete.h"
     #import "ar/com/oxenstudio/paq2/PruebaPaquete.h"
    
    
    ar_com_oxenstudio_paq1_PruebaPaquete *p = [[ar_com_oxenstudio_paq1_PruebaPaquete alloc] init];
    ar_com_oxenstudio_paq2_PruebaPaquete *p2 = [[ar_com_oxenstudio_paq2_PruebaPaquete alloc] init];
    

提交回复
热议问题