1

I define CountryInfo class in "CountryInfoLoader.h";

@interface CountryInfo : NSObject

@property(nonatomic,strong)NSString * code;
@property(nonatomic,strong)NSString * name;
@property(nonatomic,strong)NSString * prefix;

@end

@interface CountryInfoLoader : NSObject

+ (CountryInfo*)currentCountry;
+ (NSArray*)loadAllCountries;
+ (NSDictionary*)loadGroupCountries;

@end

So: 1. How could I describe "CountryInfo" defining in "CountryInfoLoader.h"? innner class(like java), instance-method, property, or what?

  1. what is the difference betwwen the defination in "CountryInfoLoader.h" and extracting to "CountryInfo.h"/"CountryInfo.m"?
Brian Li
  • 43
  • 5
  • Objective-C doesn't have namespaces, and it doesn't have inner classes. The closest you can get is to define the class entirely in the implementation file (`.m`). If you need to refer to it in the `@interface`, use `@class`. – Avi Jun 14 '16 at 08:20
  • what is the difference betwwen the defination in "CountryInfoLoader.h" and extracting to "CountryInfo.h" / "CountryInfo.m"? – Brian Li Jun 14 '16 at 08:32
  • Visibility to the compiler. Symbols defined in a single compilation unit (a single file: e.g. .m, .c, .cpp, etc.) are not visible to other compilation units. This gives some semblance of privacy. Objective-C is very dynamic, though, so at runtime there's virtually no privacy at all. – Avi Jun 14 '16 at 08:43
  • I think the OP is attempting to "hide this class away" in order to avoid linker errors. See [his other recent question](http://stackoverflow.com/questions/37805510/about-other-linker-flag-objc). It won't end well. – Droppy Jun 14 '16 at 08:45
  • But i define it in “"CountryInfoLoader.h"”, is it invisiable also? – Brian Li Jun 14 '16 at 09:04

0 Answers0