我在使用NSParameterAssert的任何地方都遇到了编译错误.例如:
-(instancetype)initForPlot:(CPTPlot *)plot withFunction:(CPTDataSourceFunction)function
{
NSParameterAssert([plot isKindOfClass:[CPTScatterPlot class]]);
NSParameterAssert(function);
if ( (self = [self initForPlot:plot]) ) {
dataSourceFunction = function;
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
代码使用Xcode 6.2编译得很好但是它给了我以下Xcode 6.3的错误:
/Users/xxxx/Project/App/Presentation/CorePlot/Source/CPTFunctionDataSource.m:110:5: Using %s directive in NSString which is being passed as a formatting argument to the formatting method
我在线查询并没有看到有关错误消息的信息.
我正在使用的临时修复程序如下:
#undef NSParameterAssert
#define NSParameterAssert(condition) ({\
do {\
_Pragma("clang diagnostic push")\
_Pragma("clang diagnostic ignored \"-Wcstring-format-directive\"")\
NSAssert((condition), @"Invalid parameter not satisfying: %s", #condition);\
_Pragma("clang diagnostic pop")\
} while(0);\
})
Run Code Online (Sandbox Code Playgroud)
不过应该有一个更好的解决方案.