我想要类似的功能,比如 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 中实现这一点?