开发者

"incompatible type in initializtion"

my caller-code looks like this:

NSDictionary *myDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
      @"a", A_KEY,
      @"b", B_KEY, 
      @"x", X_KEY,
      nil];
id exp = [[self brain] expression];

double result = [[self brain] evaluateExpression:exp
    usingVariableValues:myDictionary]; -> this is the error line
  • expression is defined as: @property (rea开发者_Python百科donly) id expression; (i do not think that's relevant)

the signature of the function "evaluateExpression:exp..." is:

" + (double)evaluateExpression:(id)anExpression
usingVariableValues:(NSDictionary *)variables;"

The error i am receiving: "incompatible type in initializtion"

I can't figure this one out - it's simply initializing a double variable with a method which returns a double. What am i doing wrong?


Try changing the plus at the beginning of the method declaration to a minus. A plus indicates a class method, and you're (as far as I can tell) calling it against an instance.

I think the above mistake is causing the compiler to not know that the method is returning a double, hence the error.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜