简体   繁体   中英

Compilation Error with NSParameterAssert with Xcode 6.3

I am getting compilation errors anywhere NSParameterAssert is used. For example:

-(instancetype)initForPlot:(CPTPlot *)plot withFunction:(CPTDataSourceFunction)function
{
    NSParameterAssert([plot isKindOfClass:[CPTScatterPlot class]]);
    NSParameterAssert(function);

    if ( (self = [self initForPlot:plot]) ) {
        dataSourceFunction = function;
    }
    return self;
}

The code compiles fine with Xcode 6.2 but it's giving me the following errors with 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

I have looked up online and have not seen information on the error message.
A temp fix I am using is the following:

#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);\
})

There should be a better solution for this though.

All you have to do is update your core-plot library to the latest version (that worked for me) BECAUSE:

If you go to Coreplot git repo ( https://github.com/core-plot/core-plot/commits/master ),

within the commits you can see:

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

That means that this problem is already fixed since Feb 15, a long time before this iOS 8.3 release, since the beta version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM