- //Song.h
- #import <Foundation/Foundation.h>
- @interface Song : NSObject
- @property (nonatomic, strong) NSString *songName; // 歌名
- @property (nonatomic, strong) NSString *singer; // 歌手
- @property (nonatomic, strong) NSString *zhuanJi; // 专辑
- @property (nonatomic, assign) double length; // 歌曲长度 (秒)
- @end
复制代码
- // Playlist.h
- #import <Foundation/Foundation.h>
- @class Song;
- @interface Playlist : NSObject
- @property (nonatomic,strong) NSString *listName; // 列表名称
- @property (nonatomic, strong) NSMutableDictionary *songSet; // 歌曲集合
- // 添加歌曲
- - (void)addSong:(Song *)song;
- // 删除歌曲
- - (void)deleteSong:(NSString *)songName;
- @end
复制代码
- // Playlist.m
- #import "Playlist.h"
- #import "Song.h"
- @implementation Playlist
- // 添加歌曲
- - (void)addSong:(Song *)song
- {
- [_songSet setObject:song forKey:song.songName];
- }
- // 删除歌曲
- - (void)deleteSong:(Song *)songName
- {
- [_songSet removeObjectForKey:songName];
- }
- @end
复制代码 |