ios – 使用Xcode 6.3编写NSParameterAssert错误

前端之家收集整理的这篇文章主要介绍了ios – 使用Xcode 6.3编写NSParameterAssert错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用NSParameterAssert的任何编译错误.例如:
  1. -(instancetype)initForPlot:(CPTPlot *)plot withFunction:(CPTDataSourceFunction)function
  2. {
  3. NSParameterAssert([plot isKindOfClass:[CPTScatterPlot class]]);
  4. NSParameterAssert(function);
  5.  
  6. if ( (self = [self initForPlot:plot]) ) {
  7. dataSourceFunction = function;
  8. }
  9. return self;
  10. }

代码使用Xcode 6.2编译很好,但是它给Xcode 6.3提供了以下错误
/Users/xxxx/Project/App/Presentation/CorePlot/Source/CPTFunctionDataSource.m:110:5:在NSString中使用%s指令作为格式化参数传递给格式化方法

我已经在线查找,没有看到有关错误信息的信息.
我正在使用的临时解决方案如下:

  1. #undef NSParameterAssert
  2. #define NSParameterAssert(condition) ({\
  3. do {\
  4. _Pragma("clang diagnostic push")\
  5. _Pragma("clang diagnostic ignored \"-Wcstring-format-directive\"")\
  6. NSAssert((condition),@"Invalid parameter not satisfying: %s",#condition);\
  7. _Pragma("clang diagnostic pop")\
  8. } while(0);\
  9. })

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

解决方法

所有你需要做的是更新你的核心图库到最新版本(这对我有用)BECAUSE:

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

在提交内可以看到:

  1. Commits on Feb 15,2015
  2. @eskroch
  3. Fixed Xcode 6.3 beta build warnings.
  4. eskroch authored on Feb 15

这意味着自2月15日以来,这个iOS 8.3发布之前很久以来,这个问题已经解决了,因为beta版本.

猜你在找的iOS相关文章