{"id":6336,"date":"2014-04-16T09:33:28","date_gmt":"2014-04-16T09:33:28","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/16\/issues-with-import-and-class-cause-_objc_class_-referenced-from-error-collection-of-common-programming-errors-2\/"},"modified":"2014-04-16T09:33:28","modified_gmt":"2014-04-16T09:33:28","slug":"issues-with-import-and-class-cause-_objc_class_-referenced-from-error-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/16\/issues-with-import-and-class-cause-_objc_class_-referenced-from-error-collection-of-common-programming-errors-2\/","title":{"rendered":"Issues with #import and @class cause _OBJC_CLASS_ referenced from error-Collection of common programming errors"},"content":{"rendered":"<p>I have two classes.<\/p>\n<h2>APPagine.h<\/h2>\n<pre><code>#import \n@interface APPagineMedia : NSObject\n@property (nonatomic, retain) NSString *Immagine;\n@property (nonatomic, retain) NSString *Video;\n@end\n\n@interface APPagineDescription : NSObject\n@property (nonatomic, retain) NSString *Descrizione;\n@end\n\n@interface APPagineSommarioLinee : NSObject\n@property (nonatomic, retain) NSString *Description;\n@property (nonatomic, assign) int IdLinea;\n@end\n\n@interface APPagineSommarioCategorie : NSObject\n@property (nonatomic, retain) NSString *Nome;\n@property (nonatomic, assign) int DestId;\n@property (nonatomic, retain) APPagineSommarioLinee *Linee;\n@end\n\n@interface APPagineSommario : NSObject\n@property (nonatomic, retain) APPagineSommarioCategorie *Categorie;\n@end\n\n@interface APPagine : NSObject\n@property (nonatomic, assign) NSString *Layout;\n@property (nonatomic, assign) int Indice;\n@property (nonatomic, retain) NSString *Titolo;\n@property (nonatomic, retain) APPagineMedia *Media;\n@property (nonatomic, retain) APPagineDescription *Descrizione;\n@property (nonatomic, retain) APPagineSommario *Sommario;\n@end\n<\/code><\/pre>\n<h2>APXmlData.h<\/h2>\n<pre><code>@interface APXmlData : NSObject\n\n@property (nonatomic, retain) NSString *Lingua;\n@property (nonatomic, assign) float Versione;\n@property (nonatomic, assign) long long Timestamp;\n@property (nonatomic, retain) APPagine    *Pagine;\n@property (nonatomic, retain) APCategorie *Categorie;\n@property (nonatomic, retain) APCarousel  *Carousel;\n\n@end\n<\/code><\/pre>\n<p>and finally in my controller interface:<\/p>\n<pre><code>#import \"APXmlData.h\"\n@interface APViewController : UIViewController\n{\n  APXmlData *_XmlData;\n}\n@end\n<\/code><\/pre>\n<p>and in implementation:<\/p>\n<pre><code>_XmlData.Timestamp = 123;\n_XmlData.Version = 1.0;\n_XmlData.Pagine = [[APPagine alloc] init];\n_XmlData.Pagine.Layout = @\"a\";\n_XmlData.Pagine.Indice = 1;\n_XmlData.Pagine.Titolo = @\"titolo\";\n\/\/[...]\n<\/code><\/pre>\n<p>But,<br \/>\nin when i go to set data to<\/p>\n<pre><code>_XmlData.Pagine = [[APPagine alloc] init];\n<\/code><\/pre>\n<p>he returns me a linker error, the classic<\/p>\n<blockquote>\n<p>Undefined symbols for architecture i386: &#8220;_OBJC_CLASS_$_APPagineDescription&#8221;, referenced from:<\/p>\n<p>objc-class-ref in APPagine.o<\/p>\n<p>&#8220;_OBJC_CLASS_$_APPagineMedia&#8221;, referenced from: objc-class-ref in APViewController.o<\/p>\n<p>objc-class-ref in APPagine.o<\/p>\n<p>&#8220;_OBJC_CLASS_$_APPagineSommario&#8221;, referenced from:<br \/>\nobjc-class-ref in APPagine.o<\/p>\n<p>ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)<\/p>\n<\/blockquote>\n<p>My question is: <strong>what is correct way to <code>import<\/code> the classes in my controller?<\/strong><br \/>\nShould be use <code>#import<\/code> or <code>@class<\/code>? In that order?<br \/>\nWhat are the classes that require <code>@class<\/code> or <code>#import<\/code>?<\/p>\n<h2>NOTE<\/h2>\n<p>In <strong>Build -&gt; Compile Sources<\/strong>, both files are properly configured.<br \/>\nIf i remove <code>_XmlData.Pagine = [[APPagine alloc] init];<\/code> the apps run well<\/p>\n<p>thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have two classes. APPagine.h #import @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; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6336","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6336"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6336\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}