开发者

What's wrong with UIColor *clr = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];?

UIColor *clr = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.开发者_运维问答0];

I have compiler errors at above line.

  1. Expected ']' before numeric constant
  2. 'UIColor' may not respond to '+colorWithRed:green:'

If I comment out that line, I don't have compiler error.

Maybe, I have this problem after I added below line in my Prefix.pch.

#define RGB(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]

I had the same compiler errror. So, I deleted that line from .pch and I cleaned all target in build menu, and recompiled. I even rebooted. I retyped. It is useless.


Most likely there is an extra character, possibly an invisible character after "green". Try re-typing the line. If that does not fix it, comment out the line to see if there are any other errors in the method/file.

If there are errors above the line, as above comment out the UIColor line and concentrate on them.


Your problem is probably somewhere else, that code looks totally fine.


That line is fine. Try looking around it.


try this instead

#define RGB(r, g, b) {return [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1];}


I had similar problem - I was getting "expected ]" and there was a little glyph under one of the parameter names i.e. "green:". It turned out I had defined colours in the header i.e #define green 0x66ff99, and this caused the conflict and said error message with the use of [UIColor colorWithRed: green: blue: alpha:].

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜