我在Xcode中有一個NSObject類和@implementation行給我一個錯誤; 未找到'initWithName:tutorID:tutorPhone:tutorEmail:'的方法定義。未找到'initWithName ...'的方法定義。錯誤
我.h文件中:
#import <Foundation/Foundation.h>
@interface TutorsItem : NSObject
@property (nonatomic, strong) NSString *tutorName;
@property (nonatomic) int tutorID;
@property (nonatomic, strong) NSString *tutorPhone;
@property (nonatomic, strong) NSString *tutorEmail;
- (id)initWithName:(NSString *)tutorName tutorID:(int)tutorID tutorPhone:(NSString *)tutorPhone tutorEmail:(NSString *)tutorEmail;
@end
我.m文件:
#import "TutorsItem.h"
@implementation TutorsItem
@synthesize tutorName = tutorName;
@synthesize tutorID = tutorID;
@synthesize tutorPhone = tutorPhone;
@synthesize tutorEmail = tutorEmail;
- (id)initWithName:(NSString *)title subtitle:(NSString *)subtitle {
self = [super init];
if (self) {
self.tutorName = tutorName;
self.tutorID = tutorID;
self.tutorPhone = tutorPhone;
self.tutorEmail = tutorEmail;
}
return self;
}
@end
的定義或實現? – Wain
錯誤是**定義** @Wain –
爲什麼您的實現方法根本不匹配您的接口方法? – Wain