【问题标题】:Incomplete Implementation on xcode4 [closed]xcode4上的不完整实现[关闭]
【发布时间】:2012-09-22 00:55:29
【问题描述】:

我只是 Objective-C 的新手,我还没有进入 cocoa touch 库,但我正在尝试遵循 Objective-C 的书并编写一些课程以进行更多练习。

我在实施声明中有一个错误,你能告诉我我犯了哪部分错误吗?

#import "getterSetter.h"

@implementation getterSetter

@synthesize airportName;

- (char) print : (char) name 
{
    return name;
}

- (int) zip : (int) zipair
{
    return zipair;
}
@end


int main(int argc,char *argv[])
{
    char *airportName;
    getterSetter *airport = [[getterSetter alloc]init];

    NSLog(@"Please enter the airport name:\n");
    scanf("%c",&airportName);

    NSLog(@"Please enter the airport name:\n");
    scanf("%c",&airportName);    

    NSLog(@"Your Airport Name is :\n");
    [airport print:*airportName];
}
#import <Foundation/Foundation.h>

@interface getterSetter : NSObject
{
    char *airportName;
    int zipCode;
    char *airportCityName;
}

- (char) print : (char) name;

- (int) zip;

@property char *airportName;

@end

【问题讨论】:

  • 你的问题太模糊了
  • Xcode 告诉我,第 2 行的不完整实现,这表明 @implementation 构造
  • 在问题中包含这些重要信息。
  • 哪个语句不需要分号?因为当我指示 _@implementation 或 _@interface ....时我没有使用。
  • 我指的是@implementation

标签: objective-c xcode cocoa-touch cocoa xcode4


【解决方案1】:

在 getterSetter.h 中,声明一个方法

- (int) zip;

但是在你实现的 .m 文件中

- (int) zip : (int) zipair

这是一种不同的方法,因此编译器会抱怨缺少- (int) zip 的实现。

【讨论】:

  • 非常感谢 :) 我只是在修改构造函数时失明了 :/ ,那个固定的代码!
猜你喜欢
  • 2011-08-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-26
  • 2012-12-02
  • 1970-01-01
  • 2013-06-15
  • 1970-01-01
相关资源
最近更新 更多