Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
Code Modernization
Browse files Browse the repository at this point in the history
  • Loading branch information
willson556 committed Jul 4, 2014
1 parent 8629d60 commit cd939d5
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 39 deletions.
18 changes: 9 additions & 9 deletions AppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ - (void)awakeFromNib

// TODO: remove 4oD
// disable 4oD and delete CH4 cache
[[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithBool:NO] forKey:@"Cache4oD_TV"];
[[NSUserDefaults standardUserDefaults] setValue:@NO forKey:@"Cache4oD_TV"];
[ch4TVCheckbox setState:NSOffState];
[ch4TVCheckbox setEnabled:NO];
[fileManager removeItemAtPath:[folder stringByAppendingPathComponent:@"ch4.cache"] error:nil];
Expand Down Expand Up @@ -196,13 +196,13 @@ - (void)awakeFromNib
// clear obsolete formats
NSMutableArray *tempTVFormats = [[NSMutableArray alloc] initWithArray:[tvFormatController arrangedObjects]];
for (TVFormat *tvFormat in tempTVFormats) {
if (![tvFormats objectForKey:[tvFormat format]]) {
if (!tvFormats[[tvFormat format]]) {
[tvFormatController removeObject:tvFormat];
}
}
NSMutableArray *tempRadioFormats = [[NSMutableArray alloc] initWithArray:[radioFormatController arrangedObjects]];
for (RadioFormat *radioFormat in tempRadioFormats) {
if (![radioFormats objectForKey:[radioFormat format]]) {
if (!radioFormats[[radioFormat format]]) {
[radioFormatController removeObject:radioFormat];
}
}
Expand Down Expand Up @@ -468,7 +468,7 @@ - (void)updateCache:(id)sender proxyError:(NSError *)proxyError

[self addToLog:@"Updating Program Index Feeds...\r" :self];

getiPlayerUpdateArgs = [[NSArray alloc] initWithObjects:getiPlayerPath,cacheExpiryArg,typeArgument,@"--nopurge",profileDirArg,proxyArg,nil];
getiPlayerUpdateArgs = @[getiPlayerPath,cacheExpiryArg,typeArgument,@"--nopurge",profileDirArg,proxyArg];
getiPlayerUpdateTask = [[NSTask alloc] init];
[getiPlayerUpdateTask setLaunchPath:@"/usr/bin/perl"];
[getiPlayerUpdateTask setArguments:getiPlayerUpdateArgs];
Expand Down Expand Up @@ -843,7 +843,7 @@ - (IBAction)copyLog:(id)sender
{
NSString *unattributedLog = [log string];
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSArray *types = [[NSArray alloc] initWithObjects:NSStringPboardType,nil];
NSArray *types = @[NSStringPboardType];
[pb declareTypes:types owner:self];
[pb setString:unattributedLog forType:NSStringPboardType];
}
Expand Down Expand Up @@ -1045,7 +1045,7 @@ - (void)getNameForProgramme:(Programme *)pro
NSString *fieldsArgument = @"--fields=index,pid";
NSString *wantedID = [pro valueForKey:@"pid"];
NSString *cacheExpiryArg = [self cacheExpiryArgument:nil];
NSArray *args = [[NSArray alloc] initWithObjects:getiPlayerPath,noWarningArg,@"--nopurge",cacheExpiryArg,[self typeArgument:nil],listArgument,profileDirArg,fieldsArgument,wantedID,nil];
NSArray *args = @[getiPlayerPath,noWarningArg,@"--nopurge",cacheExpiryArg,[self typeArgument:nil],listArgument,profileDirArg,fieldsArgument,wantedID];
[getNameTask setArguments:args];
[getNameTask setLaunchPath:@"/usr/bin/perl"];

Expand Down Expand Up @@ -1133,7 +1133,7 @@ - (void)processGetNameData:(NSString *)getNameData forProgramme:(Programme *)p
{
if ([[p showName] isEqualToString:@""] || [[p showName] isEqualToString:@"Unknown: Not in Cache"])
[p setValue:@"Unknown: Not in Cache" forKey:@"showName"];
[p setProcessedPID:[[NSNumber alloc] initWithBool:NO]];
[p setProcessedPID:@NO];
}
else
[p setProcessedPID:@YES];
Expand Down Expand Up @@ -2048,8 +2048,8 @@ - (IBAction)pvrSearch:(id)sender
NSString *searchArgument = [[NSString alloc] initWithString:searchTerms];
NSString *cacheExpiryArg = [self cacheExpiryArgument:nil];
NSString *typeArgument = [self typeArgument:nil];
NSArray *args = [[NSArray alloc] initWithObjects:getiPlayerPath,noWarningArg,cacheExpiryArg,typeArgument,@"--nopurge",
@"--listformat=<index>: <type>, ~<name> - <episode>~, <channel>, <timeadded>",searchArgument,profileDirArg,nil];
NSArray *args = @[getiPlayerPath,noWarningArg,cacheExpiryArg,typeArgument,@"--nopurge",
@"--listformat=<index>: <type>, ~<name> - <episode>~, <channel>, <timeadded>",searchArgument,profileDirArg];
[pvrSearchTask setArguments:args];

[pvrSearchTask setStandardOutput:pvrSearchPipe];
Expand Down
2 changes: 1 addition & 1 deletion Download.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ - (void)setPercentage:(double)d
{
if (d<=100.0)
{
NSNumber *value = [[NSNumber alloc] initWithDouble:d];
NSNumber *value = @(d);
[nc postNotificationName:@"setPercentage" object:self userInfo:@{@"nsDouble": value}];
}
else
Expand Down
4 changes: 2 additions & 2 deletions GTMNSString+HTML.m
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ - (NSString *)gtm_stringByEscapingHTMLUsingTable:(HTMLEscapeMap*)table
buffer2Length = 0;
}
if (val) {
[finalString appendString:[NSString stringWithCString:val->escapeSequence encoding:NSUTF8StringEncoding]];
[finalString appendString:@(val->escapeSequence)];
}
else {
// _GTMDevAssert(escapeUnicode && buffer[i] > 127, @"Illegal Character");
Expand Down Expand Up @@ -506,7 +506,7 @@ - (NSString *)gtm_stringByUnescapingFromHTML {
} else {
// "standard" sequences
for (unsigned i = 0; i < sizeof(gAsciiHTMLEscapeMap) / sizeof(HTMLEscapeMap); ++i) {
if ([escapeString isEqualToString:[NSString stringWithCString:gAsciiHTMLEscapeMap[i].escapeSequence encoding:NSUTF8StringEncoding]]) {
if ([escapeString isEqualToString:@(gAsciiHTMLEscapeMap[i].escapeSequence)]) {
[finalString replaceCharactersInRange:escapeRange withString:[NSString stringWithCharacters:&gAsciiHTMLEscapeMap[i].uchar length:1]];
break;
}
Expand Down
Binary file not shown.
16 changes: 10 additions & 6 deletions Programme.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@
NSNumber *radio;
NSString *realPID;
NSString *subtitlePath;
NSString *reasonForFailure;
NSString *availableModes;
NSString *url;
NSDate *__strong dateAired;
NSString *desc;
NSNumber *podcast;
NSString *reasonForFailure;
NSString *availableModes;
NSString *url;
NSDate *__strong dateAired;
NSString *desc;
NSNumber *podcast;

//Extended Metadata
NSNumber *duration;

}
- (id)initWithInfo:(id)sender pid:(NSString *)PID programmeName:(NSString *)SHOWNAME network:(NSString *)TVNETWORK;
- (id)initWithShow:(Programme *)show;
Expand Down
30 changes: 15 additions & 15 deletions Programme.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ - (id)initWithInfo:(id)sender pid:(NSString *)PID programmeName:(NSString *)SHOW
showName = [[[NSString alloc] initWithString:SHOWNAME] stringByDecodingHTMLEntities];
tvNetwork = [[NSString alloc] initWithString:TVNETWORK];
status = [[NSString alloc] init];
complete = [[NSNumber alloc] initWithBool:NO];
successful = [[NSNumber alloc] initWithBool:NO];
complete = @NO;
successful = @NO;
path = @"Unknown";
seriesName = [[NSString alloc] init];
episodeName = [[NSString alloc] init];
timeadded = [[NSNumber alloc] init];
processedPID = [[NSNumber alloc] initWithBool:YES];
radio = [[NSNumber alloc] initWithBool:NO];
processedPID = @YES;
radio = @NO;
subtitlePath=[[NSString alloc] init];
realPID=[[NSString alloc] init];
reasonForFailure=[[NSString alloc] init];
availableModes=[[NSString alloc] init];
desc=[[NSString alloc] init];
podcast=[[NSNumber alloc] initWithBool:NO];
podcast=@NO;
return self;
}
- (id)initWithShow:(Programme *)show
Expand All @@ -41,13 +41,13 @@ - (id)initWithShow:(Programme *)show
showName = [[[NSString alloc] initWithString:[show showName]] stringByDecodingHTMLEntities];
tvNetwork = [[NSString alloc] initWithString:[show tvNetwork]];
status = [[NSString alloc] initWithString:[show status]];
complete = [[NSNumber alloc] initWithBool:NO];
successful = [[NSNumber alloc] initWithBool:NO];
complete = @NO;
successful = @NO;
path = [[NSString alloc] initWithString:[show path]];
seriesName = [[NSString alloc] init];
episodeName = [[NSString alloc] init];
timeadded = [[NSNumber alloc] init];
processedPID = [[NSNumber alloc] initWithBool:YES];
processedPID = @YES;
radio = [show radio];
realPID = [show realPID];
subtitlePath = [show subtitlePath];
Expand All @@ -72,19 +72,19 @@ - (id)init
}
seriesName = [[NSString alloc] init];
episodeName = [[NSString alloc] init];
complete = [[NSNumber alloc] initWithBool:NO];
successful = [[NSNumber alloc] initWithBool:NO];
complete = @NO;
successful = @NO;
timeadded = [[NSNumber alloc] init];
path = @"Unknown";
processedPID = [[NSNumber alloc] initWithBool:NO];
radio = [[NSNumber alloc] initWithBool:NO];
processedPID = @NO;
radio = @NO;
url = [[NSString alloc] init];
realPID=[[NSString alloc] init];
subtitlePath=[[NSString alloc] init];
reasonForFailure=[[NSString alloc] init];
availableModes=[[NSString alloc] init];
desc=[[NSString alloc] init];
podcast=[[NSNumber alloc] initWithBool:NO];
podcast=@NO;
return self;
}
- (id)description
Expand Down Expand Up @@ -114,8 +114,8 @@ - (id) initWithCoder: (NSCoder *)coder
showName = [[NSString alloc] initWithString:[coder decodeObjectForKey:@"showName"]];
tvNetwork = [[NSString alloc] initWithString:[coder decodeObjectForKey:@"tvNetwork"]];
status = @"";
complete = [[NSNumber alloc] initWithBool:NO];
successful = [[NSNumber alloc] initWithBool:NO];
complete = @NO;
successful = @NO;
path = [[NSString alloc] initWithString:[coder decodeObjectForKey:@"path"]];
seriesName = [[NSString alloc] initWithString:[coder decodeObjectForKey:@"seriesName"]];
episodeName = [[NSString alloc] initWithString:[coder decodeObjectForKey:@"episodeName"]];
Expand Down
10 changes: 5 additions & 5 deletions RSRTVArrayController.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ @implementation RSRTVArrayController

- (void) awakeFromNib
{
[oTableView registerForDraggedTypes:[NSArray arrayWithObjects:kRSRTVMovedRowsType, nil]];
[oTableView registerForDraggedTypes:@[kRSRTVMovedRowsType]];
[self setDraggingEnabled:YES];
}

Expand Down Expand Up @@ -54,15 +54,15 @@ - (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexe
if ([self draggingEnabled] == YES)
{
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pboard declareTypes:[NSArray arrayWithObject:kRSRTVMovedRowsType] owner:self];
[pboard declareTypes:@[kRSRTVMovedRowsType] owner:self];
[pboard setData:data forType:kRSRTVMovedRowsType];
}
return [self draggingEnabled];
}

- (BOOL) tableObjectsSupportCopying
{
return [[[self arrangedObjects] objectAtIndex:0] conformsToProtocol:@protocol(NSCopying)];
return [[self arrangedObjects][0] conformsToProtocol:@protocol(NSCopying)];
}

- (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)op
Expand Down Expand Up @@ -148,7 +148,7 @@ -(void) copyObjectsInArrangedObjectsFromIndexes:(NSIndexSet*)indexSet toIndex:(N
{
copyIndex = copyFromIndex;
}
object = [objects objectAtIndex:copyIndex];
object = objects[copyIndex];
// [self insertObject:[[object copy] autorelease] atArrangedObjectIndex:insertIndex];
[self insertObject:[object copy] atArrangedObjectIndex:insertIndex];

Expand Down Expand Up @@ -180,7 +180,7 @@ -(void) moveObjectsInArrangedObjectsFromIndexes:(NSIndexSet*)indexSet toIndex:(N
}

// Get the object we're moving
object = [objects objectAtIndex:removeIndex];
object = objects[removeIndex];

// In case nobody else is retaining the object, we need to keep it alive while we move it
// [object retain];
Expand Down
2 changes: 1 addition & 1 deletion Series.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ - (id)init
showName = [[NSString alloc] init];
tvNetwork = [[NSString alloc] init];
lastFound = [[NSDate alloc] init];
added = [NSNumber numberWithDouble:[[[NSDate alloc] init] timeIntervalSince1970]];
added = @([[[NSDate alloc] init] timeIntervalSince1970]);
return self;
}
- (id)initWithShowname:(NSString *)SHOWNAME
Expand Down

0 comments on commit cd939d5

Please sign in to comment.