使用Xcode 6.3的NSParameterAssert编译错误

us_*_*vid 12 objective-c ios xcode6.3

我在使用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)

不过应该有一个更好的解决方案.

Gio*_*Ath 1

您所要做的就是将核心图库更新到最新版本(对我有用),因为:

如果你去 Coreplot git repo ( https://github.com/core-plot/core-plot/commits/master ),

在提交中您可以看到:

Commits on Feb 15, 2015
@eskroch
Fixed Xcode 6.3 beta build warnings.
eskroch authored on Feb 15
Run Code Online (Sandbox Code Playgroud)

这意味着这个问题自 2 月 15 日起就已经得到解决,距离 iOS 8.3 发布很久,距离 beta 版本还很远。