Skip to content
This repository was archived by the owner on Oct 23, 2019. It is now read-only.

Commit e2f61fc

Browse files
committed
Let's try this again
1 parent b325199 commit e2f61fc

12 files changed

+369
-122
lines changed

Classes/JustPlayedAppDelegate.m

+34-28
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#import "JustPlayedAppDelegate.h"
1010
#import "JustPlayedViewController.h"
11+
#import "Snap.h"
1112

1213
#ifdef BROMINET_ENABLED
1314
#import "ScriptRunner.h"
@@ -78,17 +79,46 @@ - (NSString*)getTestData:(NSDictionary*)data {
7879
}
7980

8081

82+
- (NSDate*)dateFromClockTime:(NSString*)clockTime;
83+
{
84+
NSDate* date = [NSDate date];
85+
NSCalendar* calendar = [NSCalendar currentCalendar];
86+
NSInteger dateUnits =
87+
NSYearCalendarUnit |
88+
NSMonthCalendarUnit |
89+
NSDayCalendarUnit;
90+
NSDateComponents* dateParts = [calendar components:dateUnits fromDate:date];
91+
92+
NSDateFormatter* format = [[[NSDateFormatter alloc] init] autorelease];
93+
[format setDateFormat:@"HH:mm"];
94+
NSDate* time = [format dateFromString:clockTime];
95+
96+
NSInteger timeUnits =
97+
NSHourCalendarUnit |
98+
NSMinuteCalendarUnit;
99+
NSDateComponents* timeParts = [calendar components:timeUnits fromDate:time];
100+
101+
NSInteger hour = [timeParts hour];
102+
NSInteger minute = [timeParts minute];
103+
104+
[dateParts setHour:hour];
105+
[dateParts setMinute:minute];
106+
107+
return [calendar dateFromComponents:dateParts];
108+
}
109+
110+
81111
- (NSString*)setTestData:(NSDictionary*)data {
82112
NSArray* stations = [data objectForKey:@"stations"];
83113
if (stations)
84114
{
85115
viewController.stations = stations;
86116
}
87117

88-
NSArray* snaps = [data objectForKey:@"snaps"];
89-
if (snaps)
118+
NSArray* plists = [data objectForKey:@"snaps"];
119+
if (plists)
90120
{
91-
[viewController setSnaps:snaps];
121+
[viewController setSnaps:[Snap snapsFromPropertyLists:plists]];
92122
}
93123

94124
NSString* lookupServer = [data objectForKey:@"lookupServer"];
@@ -100,31 +130,7 @@ - (NSString*)setTestData:(NSDictionary*)data {
100130
NSString* testTime = [data objectForKey:@"testTime"];
101131
if (testTime)
102132
{
103-
NSDate* date = [NSDate date];
104-
NSCalendar* calendar = [NSCalendar currentCalendar];
105-
NSInteger dateUnits =
106-
NSYearCalendarUnit |
107-
NSMonthCalendarUnit |
108-
NSDayCalendarUnit;
109-
NSDateComponents* dateParts = [calendar components:dateUnits fromDate:date];
110-
111-
NSDateFormatter* format = [[[NSDateFormatter alloc] init] autorelease];
112-
[format setDateFormat:@"HH:mm"];
113-
NSDate* time = [format dateFromString:testTime];
114-
115-
NSInteger timeUnits =
116-
NSHourCalendarUnit |
117-
NSMinuteCalendarUnit;
118-
NSDateComponents* timeParts = [calendar components:timeUnits fromDate:time];
119-
120-
NSInteger hour = [timeParts hour];
121-
NSInteger minute = [timeParts minute];
122-
123-
[dateParts setHour:hour];
124-
[dateParts setMinute:minute];
125-
NSDate* dateTime = [calendar dateFromComponents:dateParts];
126-
127-
viewController.testTime = dateTime;
133+
viewController.testTime = [self dateFromClockTime:testTime];
128134
}
129135

130136
[viewController refreshView];

Classes/JustPlayedViewController.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#import <UIKit/UIKit.h>
1010

11-
@class SnapsController;
1211
@class ASINetworkQueue;
1312

1413
@interface JustPlayedViewController :
@@ -18,7 +17,8 @@
1817
UIActionSheetDelegate>
1918
{
2019
NSArray* stations;
21-
SnapsController* snapsController;
20+
NSMutableArray* snaps;
21+
2222
IBOutlet UITableView* snapsTable;
2323
IBOutlet UIToolbar* toolbar;
2424
IBOutlet UIProgressView* progressBar;
@@ -28,7 +28,7 @@
2828
}
2929

3030
- (void)setStations:(NSArray*)newStations;
31-
- (void)setSnaps:(NSArray*)snaps;
31+
- (void)setSnaps:(NSArray*)newSnaps;
3232

3333
- (void)setToFactoryDefaults;
3434
- (void)loadUserData;
@@ -40,7 +40,7 @@
4040
- (IBAction)deleteButtonPressed:(id)sender;
4141

4242
@property (nonatomic, retain) NSArray* stations;
43-
@property (nonatomic, retain) SnapsController* snapsController;
43+
@property (nonatomic, copy) NSArray* snaps;
4444

4545
@property (nonatomic, retain) UITableView* snapsTable;
4646
@property (nonatomic, retain) UIToolbar* toolbar;

0 commit comments

Comments
 (0)