我有两节课。
APPagine.h
#import <Foundation/Foundation.h>
@interface APPagineMedia : NSObject
@property (nonatomic, retain) NSString *Immagine;
@property (nonatomic, retain) NSString *Video;
@end
@interface APPagineDescription : NSObject
@property (nonatomic, retain) NSString *Descrizione;
@end
@interface APPagineSommarioLinee : NSObject
@property (nonatomic, retain) NSString *Description;
@property (nonatomic, assign) int IdLinea;
@end
@interface APPagineSommarioCategorie : NSObject
@property (nonatomic, retain) NSString *Nome;
@property (nonatomic, assign) int DestId;
@property (nonatomic, retain) APPagineSommarioLinee *Linee;
@end
@interface APPagineSommario : NSObject
@property (nonatomic, retain) APPagineSommarioCategorie *Categorie;
@end
@interface APPagine : NSObject
@property (nonatomic, assign) NSString *Layout;
@property (nonatomic, assign) int Indice;
@property (nonatomic, retain) NSString *Titolo;
@property (nonatomic, retain) APPagineMedia *Media;
@property (nonatomic, retain) APPagineDescription *Descrizione;
@property (nonatomic, retain) APPagineSommario *Sommario;
@end
APXmlData.h
@interface APXmlData : NSObject
@property (nonatomic, retain) NSString *Lingua;
@property (nonatomic, assign) float Versione;
@property (nonatomic, assign) long long Timestamp;
@property (nonatomic, retain) APPagine *Pagine;
@property (nonatomic, retain) APCategorie *Categorie;
@property (nonatomic, retain) APCarousel *Carousel;
@end
最后在我的控制器界面中:
#import "APXmlData.h"
@interface APViewController : UIViewController
{
APXmlData *_XmlData;
}
@end
并在实施中:
_XmlData.Timestamp = 123;
_XmlData.Version = 1.0;
_XmlData.Pagine = [[APPagine alloc] init];
_XmlData.Pagine.Layout = @"a";
_XmlData.Pagine.Indice = 1;
_XmlData.Pagine.Titolo = @"titolo";
//[...]
但是,
当我去设置数据时
_XmlData.Pagine = [[APPagine alloc] init];
他给我一个链接器错误,经典
架构 i386 的未定义符号:
“_OBJC_CLASS_$_APPagineDescription”,引用自:
APPagine.o 中的 objc-class-ref“_OBJC_CLASS_$_APPagineMedia”,引用自:
objc-class-ref in APViewController.o
objc-class-ref in APPagine.o“_OBJC_CLASS_$_APPagineSommario”,引用自:
APPagine.o 中的 objc-class-refld:未找到体系结构 i386 的符号 clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
我的问题是:控制器中的类的正确方法是什么import
?
应该使用#import
or @class
?以该顺序?
什么是需要@class
或的课程#import
?
笔记
在Build -> Compile Sources中,两个文件都已正确配置。
如果我删除_XmlData.Pagine = [[APPagine alloc] init];
应用程序运行良好
谢谢。