-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRSSChannelSelector.m
More file actions
78 lines (61 loc) · 1.74 KB
/
RSSChannelSelector.m
File metadata and controls
78 lines (61 loc) · 1.74 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// RSSChannel.m
// iReader-RSS
//
// Created by Julien Sarazin on 16/09/12.
// Copyright (c) 2012 Julien Sarazin. All rights reserved.
//
#import "RSSChannelSelector.h"
@interface RSSChannelSelector ()
@property NSString *selectedChannel;
@end
@implementation RSSChannelSelector
@synthesize channels;
static RSSChannelSelector *_sharedRssChannel;
+ (RSSChannelSelector*)sharedRSSChannel
{
@synchronized([_sharedRssChannel class])
{
if (!_sharedRssChannel)
_sharedRssChannel = [[RSSChannelSelector alloc] init];
return _sharedRssChannel;
}
return nil;
}
+ (id)alloc
{
@synchronized([_sharedRssChannel class])
{
NSAssert(_sharedRssChannel == nil, @"Attempted to allocate a second instance of a singleton.");
_sharedRssChannel = [super alloc];
return _sharedRssChannel;
}
return nil;
}
- (id)init {
self = [super init];
if (self != nil)
{
channels = @{
Key_LeMondeEconomie:@"http://www.lemonde.fr/rss/tag/economie.xml",
key_LeMondeAlaUne:@"http://www.lemonde.fr/rss/une.xml",
key_LeMondeCulture:@"http://www.lemonde.fr/rss/tag/culture.xml",
key_LeMondeInternational:@"http://www.lemonde.fr/rss/tag/international.xml",
key_LeMondePolitique:@"http://www.lemonde.fr/rss/tag/politique.xml",
key_LeMondeLitterature:@"http://www.lemonde.fr/rss/tag/livres.xml",
key_LeMondeSport:@"http://www.lemonde.fr/rss/tag/sport.xml",
Key_LeMondeTechnologies:@"http://www.lemonde.fr/rss/tag/technologies.xml"};
}
return self;
}
- (void)setCurrentChannelFromString:(NSString *)channelUrlKey
{
self.selectedChannel = [channels valueForKey:channelUrlKey];
self.currentIndex = [channelUrlKey integerValue];
[self.delegate currentChannelChanged];
}
- (NSURL*)getCurrentChannel
{
return [NSURL URLWithString:self.selectedChannel];
}
@end