Ios 警告:不推荐使用Objective-C对象中的函数定义
升级到Xcode 6.3后,我现在收到以下警告:Ios 警告:不推荐使用Objective-C对象中的函数定义,ios,xcode,uikit,objective-c-category,Ios,Xcode,Uikit,Objective C Category,升级到Xcode 6.3后,我现在收到以下警告: Warning: Function definition inside an Objective-C object is deprecated 警告出现在NSString的一个类别中,我在其中定义了一个UIKIT_STATIC_INLINE方法 以下是违规代码: // NSString+Helpers.h #import <Foundation/Foundation.h> @interface NSString (Helpers)
Warning: Function definition inside an Objective-C object is deprecated
警告出现在NSString的一个类别中,我在其中定义了一个UIKIT_STATIC_INLINE方法
以下是违规代码:
// NSString+Helpers.h
#import <Foundation/Foundation.h>
@interface NSString (Helpers)
+ (BOOL)exampleCategoryMethod;
UIKIT_STATIC_INLINE NSString *NSStringFromCLLocationCoordinate2D(CLLocationCoordinate2D coordinate) {
return [NSString stringWithFormat:@"%f,%f", coordinate.latitude, coordinate.longitude];
}
@end
我只需将静态内联函数定义移到@interface之外 以下是修改后的代码:
// NSString+Helpers.h
#import <Foundation/Foundation.h>
UIKIT_STATIC_INLINE NSString *NSStringFromCLLocationCoordinate2D(CLLocationCoordinate2D coordinate) {
return [NSString stringWithFormat:@"%f,%f", coordinate.latitude, coordinate.longitude];
}
@interface NSString (Helpers)
+ (BOOL)exampleCategoryMethod;
@end
我只需将静态内联函数定义移到@interface之外 以下是修改后的代码:
// NSString+Helpers.h
#import <Foundation/Foundation.h>
UIKIT_STATIC_INLINE NSString *NSStringFromCLLocationCoordinate2D(CLLocationCoordinate2D coordinate) {
return [NSString stringWithFormat:@"%f,%f", coordinate.latitude, coordinate.longitude];
}
@interface NSString (Helpers)
+ (BOOL)exampleCategoryMethod;
@end
事实上,这种方法对对象C中的C++也是有效的,实际上,这种方法对对象C中的C++也是有效的。