2012-04-23 11 views
0

実装に関する2つのエラーがあります。エラーをコメントアウトしました。実装コンテキストに '@end'がありません

Header file: 
#import <Foundation/Foundation.h> 

@interface Appliance : NSObject { 
    NSString *productName; 
    int voltage; 
} 

@property (copy)NSString *productName; 
@property int voltage; 
-(id)initWithProductName:(NSString *)pn; 

@end 

実装ファイル:

#import "Appliance.h" 

@implementation Appliance //'@end' is missing in implementation context 

@synthesize productName, voltage; 

-(id)initWithProductName:(NSString *)pn 
{ 
    // Call the NSObject's init method 
    self = [super init]; 

    // Did it return something non-nil? 
    if (self) { 

    // Set the product name 
    [self setProductName:pn]; 

    // Give voltage a starting value 
    [self setVoltage:120]; 

    // Return a pointer to the new object 
    return self; 
} 
@end // unexpected '@' in program 
+0

ない場合はXcodeの質問 – Almo

答えて

6

あなたがブロック

if (self) { 

    // Set the product name 
    [self setProductName:pn]; 

    // Give voltage a starting value 
    [self setVoltage:120]; 
} // << missing 
+0

を閉じるのを忘れて、それが働いた、というキャッチいただきありがとうございます! – pdenlinger

+0

さて、同じ問題が数分前に起きたのは助けになりました;) – MByD

関連する問題