2013-06-09 4 views
0

내가 둘러 보았지만 많이 발생하지 않았습니다. 예상되는 식별자 오류가 발생했습니다. 유일한 오류입니다.iPhone app error 예상되는 식별자 또는 '('

필자가보고 된 것은 너무 오래인지 아닌지 그 때문에 경우

임 그냥 나에게 구문 분석 오류의 상점을주는 유지, 조금 혼란, 임 확실하지 받고. 여기

은 내 .H

#import <UIKit/UIKit.h> 
#import "AMRotaryProtocol.h" 

@interface AMRotaryWheel : UIControl 
-(void)drawWheel; 
@property (weak) id <AMRotaryProtocol> delegate; 
@property (nonatomic, strong) UIView *container; 
@property int numberOfSections; 

- (id) initWithFrame:(CGRect)frame andDelegate:(id)del withSections:(int)sectionsNumber; 

@end 

및 .m.

#import <QuartzCore/QuartzCore.h> 
#import "AMRotaryWheel.h" 

@interface AMRotaryWheel() 

- (void) drawWheel 
{ 
    // 1 
    container = [[UIView alloc] initWithFrame:self.frame]; 
    // 2 
    CGFloat angleSize = 2*M_PI/numberOfSections; 
    // 3 
    for (int i = 0; i < numberOfSections; i++) { 
     // 4 
     UILabel *im = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 40)]; 
     im.backgroundColor = [UIColor redColor]; 
     im.text = [NSString stringWithFormat:@"%i", i]; 
     im.layer.anchorPoint = CGPointMake(1.0f, 0.5f); 
     // 5 
     im.layer.position = CGPointMake(container.bounds.size.width/2.0, 
             container.bounds.size.height/2.0); 
     im.transform = CGAffineTransformMakeRotation(angleSize * i); 
     im.tag = i; 
     // 6 
     [container addSubview:im]; 
    } 
    // 7 
    container.userInteractionEnabled = NO; 
    [self addSubview:container]; 
} 

@end 

@implementation AMRotaryWheel 

@synthesize delegate, container, numberOfSections; 

- (id) initWithFrame:(CGRect)frame andDelegate:(id)del withSections:(int)sectionsNumber { 
// 1 - Call super init 
if ((self = [super initWithFrame:frame])) { 
    // 2 - Set properties 
    self.numberOfSections = sectionsNumber; 
    self.delegate = del; 
    // 3 - Draw wheel 
    [self drawWheel]; 
} 
return self; 
} 

- (void) drawWheel { 

} 

@end 

감사합니다.

답변

3

헤더 파일에 메서드 프로토 타입 만 있어야하는 경우 @interface (.h) 파일에 메서드 본문이 있습니다. 메서드 본문은 해당 @implementation (.m) 파일에 있어야합니다.

@interface AMRotaryWheel() 
-(void) drawWheel; 
@end 

을 그리고 AMRotaryWheel.m에, 당신은해야합니다 :

그래서 AMRotaryWheel.h에, 당신은해야

@implementation AMRotaryWheel 
-(void) drawWheel { 
    // method body here 
} 
@end 
+0

을 그것은 "예상 저를 준다 ';' – user2469203

+0

오, 무슨 일이 일어나고 있는지 보자. 메서드 본문은'@ implementation' 파일 (.m) 대신'@ interface' 파일 (.h)에 있습니다. 편집 된 답변보기 –

+0

내가 처음에 거기에 넣은 단 하나의 이유는 하나도없이 오류가 발생했다는 것입니다. – user2469203