Skip to content

Commit

Permalink
More Obj-C modernization
Browse files Browse the repository at this point in the history
  • Loading branch information
fpillet committed Dec 21, 2018
1 parent 428ac24 commit 4f92e4e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Desktop/Classes/LoggerDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ - (void)selectRun:(NSInteger)runIndex
return;
if (runIndex < 0 || runIndex >= [self.attachedLogs count])
runIndex = [self.attachedLogs count] - 1;
self.currentConnection = [self.attachedLogs objectAtIndex:runIndex];
self.currentConnection = self.attachedLogs[runIndex];
}

- (NSArray *)attachedLogsPopupNames
Expand Down Expand Up @@ -211,7 +211,7 @@ - (BOOL)writeToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSErr
// changing while we're processing it
NSInteger connectionIndex = [[self indexOfCurrentVisibleLog] integerValue];
assert(connectionIndex != NSNotFound);
LoggerConnection *connection = self.attachedLogs[connectionIndex];
LoggerConnection *connection = self.attachedLogs[(NSUInteger) connectionIndex];
__block NSArray *allMessages = nil;
dispatch_sync(connection.messageProcessingQueue , ^{
allMessages = [[NSArray alloc] initWithArray:connection.messages];
Expand Down
27 changes: 14 additions & 13 deletions Desktop/Classes/LoggerWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ - (void)tileLogTableMessages:(NSArray *)messages
case LOGMSG_TYPE_MARK:
newHeight = [LoggerMarkerCell heightForCellWithMessage:msg threadColumnWidth:_threadColumnWidth maxSize:maxCellSize showFunctionNames:_showFunctionNames];
break;
default:
break;
}
if (newHeight != cachedHeight)
[updatedMessages addObject:msg];
Expand Down Expand Up @@ -477,8 +479,7 @@ - (void)updateFilterPredicate
type:NSContainsPredicateOperatorType
options:NSCaseInsensitivePredicateOption];

[andPredicates addObject:[NSCompoundPredicate orPredicateWithSubpredicates:
[NSArray arrayWithObjects:messagePredicate, functionPredicate, nil]]];
[andPredicates addObject:[NSCompoundPredicate orPredicateWithSubpredicates:@[messagePredicate, functionPredicate]]];
}
if ([andPredicates count])
{
Expand All @@ -489,7 +490,7 @@ - (void)updateFilterPredicate
if (p == nil)
p = [NSPredicate predicateWithValue:YES];
else
p = [NSCompoundPredicate orPredicateWithSubpredicates:[NSArray arrayWithObjects:[self alwaysVisibleEntriesPredicate], p, nil]];
p = [NSCompoundPredicate orPredicateWithSubpredicates:@[[self alwaysVisibleEntriesPredicate], p]];
self.filterPredicate = p;
}

Expand Down Expand Up @@ -1231,7 +1232,7 @@ - (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableCo
{
if (tableView == _logTable && row >= 0 && row < [_displayedMessages count])
{
LoggerMessage *msg = _displayedMessages[row];
LoggerMessage *msg = _displayedMessages[(NSUInteger) row];
switch (msg.type)
{
case LOGMSG_TYPE_LOG:
Expand Down Expand Up @@ -1340,7 +1341,7 @@ - (id)tableView:(NSTableView *)tableView
row:(NSInteger)rowIndex
{
if (rowIndex >= 0 && rowIndex < [_displayedMessages count])
return _displayedMessages[rowIndex];
return _displayedMessages[(NSUInteger) rowIndex];
return nil;
}

Expand Down Expand Up @@ -1403,7 +1404,7 @@ - (BOOL)tableView:(NSTableView *)tv
{
// Only add those filters which don't exist yet
NSArray *filterSets = [_filterSetsListController arrangedObjects];
NSMutableDictionary *filterSet = filterSets[row];
NSMutableDictionary *filterSet = filterSets[(NSUInteger) row];
NSMutableArray *existingFilters = [filterSet mutableArrayValueForKey:@"filters"];
for (NSMutableDictionary *filter in newFilters)
{
Expand Down Expand Up @@ -1584,10 +1585,10 @@ - (IBAction)addFilter:(id)sender
NSDictionary *filterSet = [[_filterSetsListController selectedObjects] lastObject];
assert(filterSet != nil);
NSDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[(LoggerAppDelegate *)[NSApp delegate] nextUniqueFilterIdentifier:[filterSet objectForKey:@"filters"]], @"uid",
NSLocalizedString(@"New filter", @""), @"title",
[NSCompoundPredicate andPredicateWithSubpredicates:[NSArray array]], @"predicate",
nil];
[(LoggerAppDelegate *) NSApp.delegate nextUniqueFilterIdentifier:[filterSet objectForKey:@"filters"]], @"uid",
NSLocalizedString(@"New filter", @""), @"title",
[NSCompoundPredicate andPredicateWithSubpredicates:NSArray.array], @"predicate",
nil];
[self openFilterEditSheet:dict];
[_filterEditor addRow:self];
}
Expand Down Expand Up @@ -1642,9 +1643,9 @@ - (IBAction)createNewFilterFromQuickFilter:(id) sender
}

NSDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[(LoggerAppDelegate *)[NSApp delegate] nextUniqueFilterIdentifier:[filterSet objectForKey:@"filters"]], @"uid",
newFilterTitle, @"title",
[NSCompoundPredicate andPredicateWithSubpredicates:predicates], @"predicate",
[(LoggerAppDelegate *) NSApp.delegate nextUniqueFilterIdentifier:[filterSet objectForKey:@"filters"]], @"uid",
newFilterTitle, @"title",
[NSCompoundPredicate andPredicateWithSubpredicates:predicates], @"predicate",
nil];
[self openFilterEditSheet:dict];
}
Expand Down

0 comments on commit 4f92e4e

Please sign in to comment.