Skip to content

Commit

Permalink
Subscription Tab Now Works !
Browse files Browse the repository at this point in the history
It's getting better and better !
  • Loading branch information
Frederic Jacobs committed Nov 24, 2011
1 parent 2771336 commit cee4e0d
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 69 deletions.
77 changes: 65 additions & 12 deletions DetailController.m
Expand Up @@ -29,9 +29,13 @@ - (NSDateFormatter *)dateFormatter {
return dateFormatter;
}

- (void) viewDidLoad{
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate initializeArray];
}

// When the view appears, update the title and table contents.
- (void)viewWillAppear:(BOOL)animated {
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
self.title = show.name;
[self.tableView reloadData];
}
Expand All @@ -43,7 +47,26 @@ - (NSInteger)tableView:(UITableView *)tv numberOfRowsInSection:(NSInteger)sectio


- (void)tableView:(UITableView *)table didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[appDelegate addShow:show];
if ([indexPath row] == 3){

if ([appDelegate isSubscribedTo:show]){

[appDelegate removeShow:show];

[[[table cellForRowAtIndexPath:indexPath] textLabel]setText:@"Subscribe"];

}

else {

[appDelegate addShow:show];
[[[table cellForRowAtIndexPath:indexPath] textLabel] setText:@"You are already subscribed"];


}
}

[[table cellForRowAtIndexPath:indexPath] setSelected:FALSE];
}

- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath {
Expand All @@ -54,25 +77,55 @@ - (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSInd
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
switch (indexPath.row) {
case 0: {
case 1: {
cell.textLabel.text = NSLocalizedString(@"Starts at ", @"album label");
cell.detailTextLabel.text = show.startTime;
} break;
case 1: {
cell.textLabel.text = NSLocalizedString(@"artist", @"artist label");
case 2: {
cell.textLabel.text = NSLocalizedString(@"Ends at", @"artist label");
cell.detailTextLabel.text = show.endTime;
} break;
case 2: {
cell.textLabel.text = NSLocalizedString(@"category", @"category label");
cell.detailTextLabel.text = show.dayOfTheWeek;
case 0: {
cell.textLabel.text = NSLocalizedString(@"Weekday", @"category label");
int i = [[show dayOfTheWeek]intValue];
switch (i) {
case 1:{cell.detailTextLabel.text = @"Sunday";}
break;

case 2:{cell.detailTextLabel.text = @"Monday";}
break;

case 3:{cell.detailTextLabel.text = @"Tuesday";}
break;
case 4:{cell.detailTextLabel.text = @"Wednesday";}
break;
case 5:{cell.detailTextLabel.text = @"Thursday";}
break;
case 6:{cell.detailTextLabel.text = @"Friday";}
break;
case 7:{cell.detailTextLabel.text = @"Saterday";}
break;
default:
break;
}
} break;
case 3: {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellIdentifier];
cell.textLabel.text = @"Subscribe";
cell.textLabel.textAlignment = UITextAlignmentCenter;
}
}
return cell;


if ([appDelegate isSubscribedTo:show]){
cell.textLabel.text = @"You are already subscribed";

}

else {

cell.textLabel.text = @"Subscribe";

}
}
} return cell;
}


Expand Down
1 change: 1 addition & 0 deletions MainWindow.xib
Expand Up @@ -134,6 +134,7 @@
<int key="NSvFlags">266</int>
<string key="NSFrame">{{0, 431}, {320, 49}}</string>
<reference key="NSSuperview"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:473</string>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
Expand Down
6 changes: 5 additions & 1 deletion UCLRadio.xcodeproj/project.pbxproj
Expand Up @@ -43,6 +43,7 @@
F45224CB147E9329000A94F5 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F45224C9147E927E000A94F5 /* AudioToolbox.framework */; };
F45224CC147E936D000A94F5 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F45224A5147E8F75000A94F5 /* AVFoundation.framework */; };
F45224CF147E9386000A94F5 /* Twitter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F45224CD147E937C000A94F5 /* Twitter.framework */; };
F4CC507B147EA8A000530C84 /* loadingbutton.png in Resources */ = {isa = PBXBuildFile; fileRef = F4CC507A147EA8A000530C84 /* loadingbutton.png */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -93,6 +94,7 @@
F45224B8147E90D6000A94F5 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; };
F45224C9147E927E000A94F5 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
F45224CD147E937C000A94F5 /* Twitter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Twitter.framework; path = System/Library/Frameworks/Twitter.framework; sourceTree = SDKROOT; };
F4CC507A147EA8A000530C84 /* loadingbutton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = loadingbutton.png; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -147,6 +149,7 @@
F4334D4D147E9C47004DC63D /* Buttons */ = {
isa = PBXGroup;
children = (
F4CC507A147EA8A000530C84 /* loadingbutton.png */,
F452246A147E8932000A94F5 /* playbutton.png */,
F452246F147E8932000A94F5 /* stopbutton.png */,
F4522470147E8932000A94F5 /* Tweet.png */,
Expand All @@ -167,11 +170,11 @@
F4522437147E88BB000A94F5 = {
isa = PBXGroup;
children = (
F452244C147E88BB000A94F5 /* UCLRadio */,
F452248B147E8990000A94F5 /* Views */,
F4522484147E8971000A94F5 /* Parser */,
F4522467147E890D000A94F5 /* Images */,
F452245D147E88D0000A94F5 /* Classes */,
F452244C147E88BB000A94F5 /* UCLRadio */,
F4522445147E88BB000A94F5 /* Frameworks */,
F4522443147E88BB000A94F5 /* Products */,
);
Expand Down Expand Up @@ -340,6 +343,7 @@
F4522497147E8B59000A94F5 /* MainWindow.xib in Resources */,
F4334D4A147E9C0B004DC63D /* Icon@2x.png in Resources */,
F4334D4B147E9C0B004DC63D /* Icon.png in Resources */,
F4CC507B147EA8A000530C84 /* loadingbutton.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "1.0">
<FileBreakpoints>
<FileBreakpoint
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
isPathRelative = "1"
filePath = "UCLRadio/AppDelegate.m"
timestampString = "343856557.615852"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "34"
endingLineNumber = "34"
landmarkName = "-parseShowIntoNSDateWeekOne:"
landmarkType = "5">
</FileBreakpoint>
<FileBreakpoint
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
isPathRelative = "1"
filePath = "UCLRadio/AppDelegate.m"
timestampString = "343857670.623607"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "53"
endingLineNumber = "53"
landmarkName = "-parseShowIntoNSDateWeekOne:"
landmarkType = "5">
</FileBreakpoint>
<FileBreakpoint
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
isPathRelative = "1"
filePath = "UCLRadio/AppDelegate.m"
timestampString = "343857887.620359"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "154"
endingLineNumber = "154"
landmarkName = "-updateNotifications"
landmarkType = "5">
</FileBreakpoint>
</FileBreakpoints>
</Bucket>
7 changes: 6 additions & 1 deletion UCLRadio/AppDelegate.h
Expand Up @@ -26,6 +26,11 @@
@property (nonatomic, retain) NSMutableArray *subscribedShows;

- (void) addShow: (Show *)newShow ;
- (BOOL) alreadySubscribedToShow: (Show *)aShow ;
- (void) removeShow: (Show*)newShow ;
- (void) initializeArray;
- (BOOL) isSubscribedTo: (Show*)newShow;
- (void) printToConsole;
- (void) updateNotifications;


@end

0 comments on commit cee4e0d

Please sign in to comment.