GRi*_*e2D 2 xcode objective-c appcode xcode8
在Xcode 8中,Objective-C略有改变.现在有类级属性.例如,NSBundle的标头
@interface NSBundle : NSObject {
...
/* Methods for creating or retrieving bundle instances. */
#if FOUNDATION_SWIFT_SDK_EPOCH_AT_LEAST(8)
@property (class, readonly, strong) NSBundle *mainBundle;
#endif
+ (nullable instancetype)bundleWithPath:(NSString *)path;
- (nullable instancetype)initWithPath:(NSString *)path NS_DESIGNATED_INITIALIZER;
+ (nullable instancetype)bundleWithURL:(NSURL *)url NS_AVAILABLE(10_6, 4_0);
- (nullable instancetype)initWithURL:(NSURL *)url NS_AVAILABLE(10_6, 4_0);
+ (NSBundle *)bundleForClass:(Class)aClass;
+ (nullable NSBundle *)bundleWithIdentifier:(NSString *)identifier;
#if FOUNDATION_SWIFT_SDK_EPOCH_AT_LEAST(8)
@property (class, readonly, copy) NSArray<NSBundle *> *allBundles;
@property (class, readonly, copy) NSArray<NSBundle *> *allFrameworks;
#endif
...
Run Code Online (Sandbox Code Playgroud)
看看,主要包.现在它被声明为property但是带有class关键字.我认为它代表着class level property.好.
向下滚动后,我找到了这些代码.
#define NSLocalizedString(key, comment) \
[NSBundle.mainBundle localizedStringForKey:(key) value:@"" table:nil]
#define NSLocalizedStringFromTable(key, tbl, comment) \
[NSBundle.mainBundle localizedStringForKey:(key) value:@"" table:(tbl)]
Run Code Online (Sandbox Code Playgroud)
看看,如何mainBundle访问.但我使用JetBrains的AppCode,这个IDE将这样的结构视为无效代码.AND,[NSBundle mainBundle]变为无效,AS + (instancetype)mainBundle方法不存在.
我的问题是否 可以在不切换Xcode的情况下以某种方式切换到旧的ObjectiveC样式编码?
@property (class, readonly, strong) NSBundle *mainBundle;
Run Code Online (Sandbox Code Playgroud)
这相当于此(有一些额外的元数据可以帮助静态分析器和Swift API生成):
+ (NSBundle *)mainBundle;
Run Code Online (Sandbox Code Playgroud)
如果您的IDE /编译器随后未[NSBundle mainBundle]正确编译(或其中的等效编译器),那么您的IDE /编译器将被破坏.
| 归档时间: |
|
| 查看次数: |
1039 次 |
| 最近记录: |