0

我收到此错误消息并匹配我的括号并且找不到任何错误。你能找出问题所在吗?

谢谢你。

错误信息在相关行被注释掉;文件名是 MyHorizLine.m:

#import "MyHorizLine.h"

@implementation MyHorizLine

-(id)initWithCoder:(NSCoder *)decoder
{
  self [super initWithCoder:decoder]; //Missing '[' at message send expression
  if (self) {
    self.backgroundColor = [UIColor clearColor];

  }
  return self;
}

-(void)drawRect:(CGRect)rect
{
  CGContextRef c = UIGraphicsGetCurrentContext();
  CGContextMoveToPoint(c, 0, 0);
  CGContextAddLineToPoint(c, self.bounds.size.width, 0);
  CGContextStrokePath(c);

}
@end
4

2 回答 2

1

该行应为

self = [super initWithCoder:decoder];
于 2012-06-26T23:33:08.210 回答
1

你错过了一个=

self [super initWithCoder:decoder];

应该

self = [super initWithCoder:decoder];
于 2012-06-26T23:33:16.443 回答