这是我第一次尝试创建一个对象来存储我的数据并且遇到了一些麻烦。我不确定我是否以正确的方式去做这件事。
歌曲.h:
#import <Foundation/Foundation.h>
@interface Song : NSObject{
NSString *songID;
NSString *title;
NSString *artist;
NSString *album;
NSString *length;
NSString *votes;
}
-(void)setSongID:(NSString*) p_songId;
-(void)settitle:(NSString*) p_title;
-(void)setartist:(NSString*)p_artist;
-(void)setalbum:(NSString*) p_album;
-(void)setlength:(NSString*) p_length;
-(void)setvotes:(NSString*) p_votes;
-(NSString*)getSongID;
-(NSString*)gettitle;
-(NSString*)getartist;
-(NSString*)getalbum;
-(NSString*)getlength;
-(NSString*)getvotes;
@end
歌曲.m
#import "Song.h"
@implementation Song
-(void)setSongID:(NSString*) p_songId;{
}
-(void)settitle:(NSString*) p_title{
}
-(void)setartist:(NSString*)p_artist{
}
-(void)setalbum:(NSString*) p_album{
}
-(void)setlength:(NSString*) p_length{
}
-(void)setvotes:(NSString*) p_votes{
}
-(NSString*)getSongID{
}
-(NSString*)gettitle{
}
-(NSString*)getartist{
}
-(NSString*)getalbum{
}
-(NSString*)getlength{
}
-(NSString*)getvotes{
}
@end
我的实现文件看不到任何变量,例如我无法设置 songIDself.songID = p_songID
Objective-c 是否有处理这些 setter/getter 的内置方式,我是不是走错了路?