-
Notifications
You must be signed in to change notification settings - Fork 2
/
SRFactory.m
52 lines (45 loc) · 1.97 KB
/
SRFactory.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// SRFactory.m
// Soundrocket
//
// Created by Sebastian Boldt on 14.06.15.
// Copyright © 2015 sebastianboldt. All rights reserved.
//
#import "SRFactory.h"
@implementation SRFactory
+(id)createObjectFromDictionary:(NSDictionary*)dictionary {
if ([[dictionary objectForKey:@"type"] isEqualToString:@"track"]) {
Track * track = [[Track alloc]initWithDictionary:[dictionary objectForKey:@"origin"] error:nil];
if(track){
return track; }
} else if ([[dictionary objectForKey:@"type"] isEqualToString:@"track-repost"]) {
TrackRepost * trackRepost = [[TrackRepost alloc]initWithDictionary:[dictionary objectForKey:@"origin"] error:nil];
if(trackRepost){
return trackRepost; }
} else if ([[dictionary objectForKey:@"type"] isEqualToString:@"playlist"]) {
//Playlist * playlist;
Playlist * playlist= [[Playlist alloc]initWithDictionary:[dictionary objectForKey:@"origin"] error:nil];
if(playlist){
return playlist;
}
} else if ([[dictionary objectForKey:@"type"] isEqualToString:@"playlist-repost"]) {
PlaylistRepost * playlistRepost= [[PlaylistRepost alloc]initWithDictionary:[dictionary objectForKey:@"origin"] error:nil];
if(playlistRepost){
return playlistRepost;
}
}
return nil;
}
+(Track*)createTrackFromDictionary:(NSDictionary*)dictionary {
return [[Track alloc] initWithDictionary:dictionary error:nil];
}
+(Playlist*)createPlaylistFromDictionary:(NSDictionary*)dictionary {
return [[Playlist alloc] initWithDictionary:dictionary error:nil];
}
+(User*)createUserFromDictionary:(NSDictionary*)dictionary {
return [[User alloc] initWithDictionary:dictionary error:nil];
}
+(Comment*)createCommentFromDictionary:(NSDictionary*)dictionary{
return [[Comment alloc] initWithDictionary:dictionary error:nil];
}
@end