0

下面的代码给我一个错误“银行帐户没有可见的@interface声明选择器getAccountNumber”为什么?请帮忙

// BankAccount.h  
#import <Foundation/Foundation.h>  
@interface BankAccount: NSObject  
@property long accountNumber;  
@end  

// BankAccount.m  
#import "BankAccount.h"  
@implementation BankAccount  
@end

//main.m  
#import <Foundation/Foundation.h>  
#import "BankAccount.h"  
int main (int argc, const char * argv[])  {  
    BankAccount *account1 = [[BankAccount alloc] init];  
    [account1 setAccountNumber: 34543212];  
    NSLog(@" Account No = %li",  [account1 getAccountNumber]);  
    return 0;  
}
4

2 回答 2

3

生成的吸气剂是accountNumber,不是getAccountNumber

于 2013-01-09T02:52:36.597 回答
1

更改[account1 getAccountNumber][account1 accountNumber]

于 2013-01-09T02:50:52.007 回答