我新的目标CObjective-C是否禁止使用结构?
我试图用一个简单的struct
并得到
arc forbids objective-c objects in struct
Looking up ARC,看起来这是一个定义目标C syntaxt规范 - 是正确的?
其次,如果不允许使用struct
,我该怎么办?
谢谢!
编辑:一些代码作为样品
@implementation Cities {
// The goal is to have a struct that holds information about a city,
// like when a person started and ended living there.
// I was trying to make this struct an instance variable of the Cities
// class
// XCode doesn't like the below struct definition
struct City
{
NSString *name;
int *_startYear;
int *_endYear;
};
}
显示代码,为什么你想要一个结构? – Wain 2015-02-12 07:39:11
现在没有什么特别的原因,我只是玩弄代码示例,并想知道为什么当使用'struct'的时候出现上述错误。如果不宜采用,那很好,我不会长期使用它。我更感兴趣的是为什么它抛出那个错误。谢谢! – user2490003 2015-02-12 07:43:26
我不记得确切的原因,你可以使用结构只是不要把类指针放在它们中。 – Wain 2015-02-12 07:45:17