开发者

Incompatible Types in Initialization

I have the following code in a subroutine that produces an incompatible types in initialization error on the varVal library in the subroutine evaluateExpression:

NSDictionary *varVal;

for (int i=0; i<varCount; i++) { 
    [varVal setObject:[(i+1)*2 stringValue] forKey:[i stringValue]]; 
}

double result =[[self brain] evaluateExpression:[[self brain] expression]
usingVariableValues:varVal];

My subroutine declaration in the brain.h file is:

    +(double)evaluateExpression:(id)anExpression
    usingVariableValues:(NSDictio开发者_如何学Cnary *)variables;

I'd appreciate any help.


+(double)evaluateExpression:(id)anExpression is a class method not an instance method.

try

double result =[brain evaluateExpression:[[self brain] expression] usingVariableValues:varVal];

and as a style point classes should generally be capped for easy reading as in...

@interface Brain : NSObject

....

double result =[Brain evaluateExpression:[[self brain] expression] usingVariableValues:varVal];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜