I have made a class library for Windows Mobile in C# that uses a Web Service, now I want to create one for iPhone development. And I need to keep the same class structures in all of the libraries. In C# I have class structures that look like this
我在C#中为使用Web服务的Windows Mobile创建了一个类库,现在我想创建一个用于iPhone开发的类库。我需要在所有库中保持相同的类结构。在C#中,我的类结构看起来像这样
public class Access
{
public const long Version = 1;
public long Checker;
public class Data
{
public long AcountId;
public string SessionKeys;
}
}
I know that in Objective C class structures inside class are not permitted. But I want to know the best way to mimic or copy this class structure. I added objects of Data class inside Access Class but I'm tot sure that it's the best way. Anybody knows a better way or any ideas please tell. Oh and if someone knows a depth-in in Objective C pointer or class structure tutorial please leave a link.
我知道在Objective C类中的结构是不允许的。但我想知道模仿或复制这个类结构的最佳方法。我在Access Class中添加了Data类的对象,但我确信它是最好的方法。任何人都知道更好的方式或任何想法请告诉。哦,如果有人知道Objective C指针或类结构教程中的深度,请留下链接。
3 个解决方案
#1
0
I think that your best bet is to just create 2 classes: Access
and Access_Data
.
我认为最好的办法就是创建两个类:Access和Access_Data。
#2
0
This functionality is known as Nested Classes. See this forum post for some help on how to mimic them in Objective C.
此功能称为嵌套类。有关如何在Objective C中模仿它们的一些帮助,请参阅此论坛帖子。
#3
0
Why do you need to keep it as nested classes? Does the inner class have behavior or is it just data? If you don't need Access.Data to have behavior (e.g.):
为什么需要将它保留为嵌套类?内部类有行为还是只是数据?如果您不需要Access.Data来执行行为(例如):
typedef struct _AccessData {
long AccoountId;
NSString sessionKeys;
} AccessData;
@interface Access: NSObject {
.
.
AccessData Data;
}
@end
#1
0
I think that your best bet is to just create 2 classes: Access
and Access_Data
.
我认为最好的办法就是创建两个类:Access和Access_Data。
#2
0
This functionality is known as Nested Classes. See this forum post for some help on how to mimic them in Objective C.
此功能称为嵌套类。有关如何在Objective C中模仿它们的一些帮助,请参阅此论坛帖子。
#3
0
Why do you need to keep it as nested classes? Does the inner class have behavior or is it just data? If you don't need Access.Data to have behavior (e.g.):
为什么需要将它保留为嵌套类?内部类有行为还是只是数据?如果您不需要Access.Data来执行行为(例如):
typedef struct _AccessData {
long AccoountId;
NSString sessionKeys;
} AccessData;
@interface Access: NSObject {
.
.
AccessData Data;
}
@end