Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone Objective-C中的类内类_Iphone_Objective C_Ipad - Fatal编程技术网

Iphone Objective-C中的类内类

Iphone Objective-C中的类内类,iphone,objective-c,ipad,Iphone,Objective C,Ipad,我想要类似于Objective-C中类中的类的功能 一种方法是创建单独的NSObject类,但我必须为此创建20个类 在Objective-C中,对于类功能中的类是否有任何替代方案 就像在java中一样: public class SessionDBConstants { public static String DATABASE_NAME = "session.db"; public static class Grade { public static f

我想要类似于Objective-C中类中的类的功能

一种方法是创建单独的
NSObject
类,但我必须为此创建20个类

在Objective-C中,对于类功能中的类是否有任何替代方案

就像在java中一样:

public class SessionDBConstants {

    public static String DATABASE_NAME = "session.db";

    public static class Grade {

        public static final String Table = "grades";
        public static final String RowId = "id";
        public static final String ScheduleID = "schedule_id";
        public static final String Level = "level";
        public static final String Label = "label";
        public static final String Thershold = "thershold";

        public static final String CreateStmt = "create table grades"
                + "(id integer primary key autoincrement, schedule_id int, level int, label varchar, thershold int )";

        public static final String DropStmt = "drop table if exists grades;";

    }
}

如何在Objective-C中实现这一点?

对不起我认为我对这个问题的意思有点误解。 在您的类中,您可以启动另一个@implementation

.h
@interface classOne : NSObject
@end
@interface classTwo : NSObject
@end

.m
@implementation classOne
@end

@implementation classTwo
@end
希望能有帮助。
BooRanger

一个有用的模式可能是这里描述的类集群:

这里有一个非常清晰的概念示例:

你能详细解释一下你想要实现的目标吗?好的,我会用codeNo编辑这个问题,Objective-C不支持这一点(它也与Xcode无关).我知道,但是我还有其他的选择吗?不,
struct
不会给你
@class
能给你的一切。嵌套类实际上只与保护有关;您可以在不同的类中执行相同的操作。