Adopting lightweight generics (#2974)

This commit is contained in:
Antoine Cœur 2022-04-30 06:51:40 +08:00 committed by GitHub
parent aafedcaae1
commit 34ec2f5aa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 141 additions and 132 deletions

View File

@ -15,7 +15,7 @@
@property(nonatomic) blocklistDownloadState fState;
- (void)startDownload;
- (void)decompressFrom:(NSURL*)file to:(NSURL*)destination error:(NSError**)error;
- (BOOL)decompressFrom:(NSURL*)file to:(NSURL*)destination error:(NSError**)error;
@end
@ -185,27 +185,27 @@ BlocklistDownloader* fBLDownloader = nil;
[task resume];
}
- (void)decompressFrom:(NSURL*)file to:(NSURL*)destination error:(NSError**)error
- (BOOL)decompressFrom:(NSURL*)file to:(NSURL*)destination error:(NSError**)error
{
if ([self untarFrom:file to:destination])
{
return;
return YES;
}
if ([self unzipFrom:file to:destination])
{
return;
return YES;
}
if ([self gunzipFrom:file to:destination])
{
return;
return YES;
}
// If it doesn't look like archive just copy it to destination
else
{
[NSFileManager.defaultManager copyItemAtURL:file toURL:destination error:error];
return [NSFileManager.defaultManager copyItemAtURL:file toURL:destination error:error];
}
}

View File

@ -2,7 +2,7 @@
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
@interface BonjourController : NSObject<NSNetServiceDelegate>

View File

@ -62,24 +62,24 @@ typedef NS_ENUM(unsigned int, addType) { //
- (void)resumeSelectedTorrentsNoWait:(id)sender;
- (void)resumeWaitingTorrents:(id)sender;
- (void)resumeTorrentsNoWait:(NSArray*)torrents;
- (void)resumeTorrentsNoWait:(NSArray<Torrent*>*)torrents;
- (void)stopSelectedTorrents:(id)sender;
- (void)stopAllTorrents:(id)sender;
- (void)stopTorrents:(NSArray*)torrents;
- (void)stopTorrents:(NSArray<Torrent*>*)torrents;
- (void)removeTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData;
- (void)confirmRemoveTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData;
- (void)removeTorrents:(NSArray<Torrent*>*)torrents deleteData:(BOOL)deleteData;
- (void)confirmRemoveTorrents:(NSArray<Torrent*>*)torrents deleteData:(BOOL)deleteData;
- (void)removeNoDelete:(id)sender;
- (void)removeDeleteData:(id)sender;
- (void)clearCompleted:(id)sender;
- (void)moveDataFilesSelected:(id)sender;
- (void)moveDataFiles:(NSArray*)torrents;
- (void)moveDataFiles:(NSArray<Torrent*>*)torrents;
- (void)copyTorrentFiles:(id)sender;
- (void)copyTorrentFileForTorrents:(NSMutableArray*)torrents;
- (void)copyTorrentFileForTorrents:(NSMutableArray<Torrent*>*)torrents;
- (void)copyMagnetLinks:(id)sender;
@ -92,7 +92,7 @@ typedef NS_ENUM(unsigned int, addType) { //
- (void)verifySelectedTorrents:(id)sender;
- (void)verifyTorrents:(NSArray*)torrents;
@property(nonatomic, readonly) NSArray* selectedTorrents;
@property(nonatomic, readonly) NSArray<Torrent*>* selectedTorrents;
@property(nonatomic, readonly) PrefsController* prefsController;
- (void)showPreferenceWindow:(id)sender;

View File

@ -255,9 +255,9 @@ static void removeKeRangerRansomware()
@property(nonatomic, readonly) tr_session* fLib;
@property(nonatomic, readonly) NSMutableArray* fTorrents;
@property(nonatomic, readonly) NSMutableArray<Torrent*>* fTorrents;
@property(nonatomic, readonly) NSMutableArray* fDisplayedTorrents;
@property(nonatomic, readonly) NSMutableDictionary* fTorrentHashes;
@property(nonatomic, readonly) NSMutableDictionary<NSString*, Torrent*>* fTorrentHashes;
@property(nonatomic, readonly) InfoWindowController* fInfoController;
@property(nonatomic) MessageWindowController* fMessageController;
@ -282,14 +282,14 @@ static void removeKeRangerRansomware()
@property(nonatomic) Badger* fBadger;
@property(nonatomic) NSMutableArray* fAutoImportedNames;
@property(nonatomic) NSMutableArray<NSString*>* fAutoImportedNames;
@property(nonatomic) NSTimer* fAutoImportTimer;
@property(nonatomic) NSMutableDictionary* fPendingTorrentDownloads;
@property(nonatomic) NSMutableDictionary<NSURL*, id>* fPendingTorrentDownloads;
@property(nonatomic) NSMutableSet* fAddingTransfers;
@property(nonatomic) NSMutableSet<Torrent*>* fAddingTransfers;
@property(nonatomic) NSMutableSet* fAddWindows;
@property(nonatomic) NSMutableSet<NSWindowController*>* fAddWindows;
@property(nonatomic) URLSheetWindowController* fUrlSheetController;
@property(nonatomic) BOOL fGlobalPopoverShown;
@ -1612,7 +1612,7 @@ static void removeKeRangerRansomware()
[self resumeTorrentsNoWait:torrents];
}
- (void)resumeTorrentsNoWait:(NSArray*)torrents
- (void)resumeTorrentsNoWait:(NSArray<Torrent*>*)torrents
{
//iterate through instead of all at once to ensure no conflicts
for (Torrent* torrent in torrents)
@ -1633,7 +1633,7 @@ static void removeKeRangerRansomware()
[self stopTorrents:self.fTorrents];
}
- (void)stopTorrents:(NSArray*)torrents
- (void)stopTorrents:(NSArray<Torrent*>*)torrents
{
//don't want any of these starting then stopping
for (Torrent* torrent in torrents)
@ -1652,7 +1652,7 @@ static void removeKeRangerRansomware()
[self fullUpdateUI];
}
- (void)removeTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData
- (void)removeTorrents:(NSArray<Torrent*>*)torrents deleteData:(BOOL)deleteData
{
if ([self.fDefaults boolForKey:@"CheckRemove"])
{
@ -1676,7 +1676,7 @@ static void removeKeRangerRansomware()
NSUInteger const selected = torrents.count;
if (selected == 1)
{
NSString* torrentName = ((Torrent*)torrents[0]).name;
NSString* torrentName = torrents[0].name;
if (deleteData)
{
@ -1753,7 +1753,7 @@ static void removeKeRangerRansomware()
[self confirmRemoveTorrents:torrents deleteData:deleteData];
}
- (void)confirmRemoveTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData
- (void)confirmRemoveTorrents:(NSArray<Torrent*>*)torrents deleteData:(BOOL)deleteData
{
//miscellaneous
for (Torrent* torrent in torrents)
@ -1872,7 +1872,7 @@ static void removeKeRangerRansomware()
- (void)clearCompleted:(id)sender
{
NSMutableArray* torrents = [NSMutableArray array];
NSMutableArray<Torrent*>* torrents = [NSMutableArray array];
for (Torrent* torrent in self.fTorrents)
{
@ -1887,7 +1887,7 @@ static void removeKeRangerRansomware()
NSString *message, *info;
if (torrents.count == 1)
{
NSString* torrentName = ((Torrent*)torrents[0]).name;
NSString* torrentName = torrents[0].name;
message = [NSString
stringWithFormat:NSLocalizedString(@"Are you sure you want to remove \"%@\" from the transfer list?", "Remove completed confirm panel -> title"),
torrentName];
@ -1936,7 +1936,7 @@ static void removeKeRangerRansomware()
[self moveDataFiles:self.fTableView.selectedTorrents];
}
- (void)moveDataFiles:(NSArray*)torrents
- (void)moveDataFiles:(NSArray<Torrent*>*)torrents
{
NSOpenPanel* panel = [NSOpenPanel openPanel];
panel.prompt = NSLocalizedString(@"Select", "Move torrent -> prompt");
@ -1950,7 +1950,7 @@ static void removeKeRangerRansomware()
{
panel.message = [NSString
stringWithFormat:NSLocalizedString(@"Select the new folder for \"%@\".", "Move torrent -> select destination folder"),
((Torrent*)torrents[0]).name];
torrents[0].name];
}
else
{
@ -1974,7 +1974,7 @@ static void removeKeRangerRansomware()
[self copyTorrentFileForTorrents:[[NSMutableArray alloc] initWithArray:self.fTableView.selectedTorrents]];
}
- (void)copyTorrentFileForTorrents:(NSMutableArray*)torrents
- (void)copyTorrentFileForTorrents:(NSMutableArray<Torrent*>*)torrents
{
if (torrents.count == 0)
{
@ -2100,7 +2100,7 @@ static void removeKeRangerRansomware()
[self verifyTorrents:self.fTableView.selectedTorrents];
}
- (void)verifyTorrents:(NSArray*)torrents
- (void)verifyTorrents:(NSArray<Torrent*>*)torrents
{
for (Torrent* torrent in torrents)
{
@ -2110,7 +2110,7 @@ static void removeKeRangerRansomware()
[self applyFilter];
}
- (NSArray*)selectedTorrents
- (NSArray<Torrent*>*)selectedTorrents
{
return self.fTableView.selectedTorrents;
}
@ -2365,8 +2365,8 @@ static void removeKeRangerRansomware()
NSParameterAssert(hash != nil);
__block Torrent* torrent = nil;
[self.fTorrents enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id obj, NSUInteger idx, BOOL* stop) {
if ([((Torrent*)obj).hashString isEqualToString:hash])
[self.fTorrents enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(Torrent* obj, NSUInteger idx, BOOL* stop) {
if ([obj.hashString isEqualToString:hash])
{
torrent = obj;
*stop = YES;
@ -2813,14 +2813,16 @@ static void removeKeRangerRansomware()
//to count, we need each string in at least 1 tracker
[searchStrings enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id searchString, NSUInteger idx, BOOL* stop) {
__block BOOL found = NO;
[trackers enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id tracker, NSUInteger idx, BOOL* stopTracker) {
if ([tracker rangeOfString:searchString options:(NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)]
.location != NSNotFound)
{
found = YES;
*stopTracker = YES;
}
}];
[trackers enumerateObjectsWithOptions:NSEnumerationConcurrent
usingBlock:^(NSString* tracker, NSUInteger idx, BOOL* stopTracker) {
if ([tracker rangeOfString:searchString
options:(NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)]
.location != NSNotFound)
{
found = YES;
*stopTracker = YES;
}
}];
if (!found)
{
removeTextField = YES;
@ -2849,7 +2851,7 @@ static void removeKeRangerRansomware()
return YES;
}];
NSArray* allTorrents = [self.fTorrents objectsAtIndexes:indexesOfNonFilteredTorrents];
NSArray<Torrent*>* allTorrents = [self.fTorrents objectsAtIndexes:indexesOfNonFilteredTorrents];
//set button tooltips
if (self.fFilterBar)
@ -2944,7 +2946,7 @@ static void removeKeRangerRansomware()
if (self.fAddingTransfers)
{
NSIndexSet* newAddIndexes = [allTorrents indexesOfObjectsAtIndexes:addIndexes options:NSEnumerationConcurrent
passingTest:^BOOL(id obj, NSUInteger idx, BOOL* stop) {
passingTest:^BOOL(Torrent* obj, NSUInteger idx, BOOL* stop) {
return [self.fAddingTransfers containsObject:obj];
}];
@ -3341,7 +3343,7 @@ static void removeKeRangerRansomware()
path = path.stringByExpandingTildeInPath;
NSArray* importedNames;
NSArray<NSString*>* importedNames;
if (!(importedNames = [NSFileManager.defaultManager contentsOfDirectoryAtPath:path error:NULL]))
{
return;

View File

@ -37,7 +37,7 @@
@property(nonatomic, readonly) tr_metainfo_builder* fInfo;
@property(nonatomic, readonly) NSURL* fPath;
@property(nonatomic) NSURL* fLocation;
@property(nonatomic) NSMutableArray* fTrackers;
@property(nonatomic) NSMutableArray<NSString*>* fTrackers;
@property(nonatomic) NSTimer* fTimer;
@property(nonatomic) BOOL fStarted;

View File

@ -16,7 +16,7 @@
@property(nonatomic, readonly) uint64_t size;
@property(nonatomic, readonly) NSImage* icon;
@property(nonatomic, readonly) BOOL isFolder;
@property(nonatomic, readonly) NSMutableArray* children;
@property(nonatomic, readonly) NSMutableArray<FileListNode*>* children;
@property(nonatomic, readonly) NSIndexSet* indexes;

View File

@ -29,14 +29,14 @@ typedef NS_ENUM(unsigned int, filePriorityMenuTag) { //
@interface FileOutlineController ()
@property(nonatomic) NSMutableArray* fFileList;
@property(nonatomic) NSMutableArray<FileListNode*>* fFileList;
@property(nonatomic) IBOutlet FileOutlineView* fOutline;
@property(nonatomic, readonly) NSMenu* menu;
- (NSUInteger)findFileNode:(FileListNode*)node
inList:(NSArray*)list
inList:(NSArray<FileListNode*>*)list
atIndexes:(NSIndexSet*)range
currentParent:(FileListNode*)currentParent
finalParent:(FileListNode**)parent;
@ -683,7 +683,7 @@ typedef NS_ENUM(unsigned int, filePriorityMenuTag) { //
}
- (NSUInteger)findFileNode:(FileListNode*)node
inList:(NSArray*)list
inList:(NSArray<FileListNode*>*)list
atIndexes:(NSIndexSet*)indexes
currentParent:(FileListNode*)currentParent
finalParent:(FileListNode* __autoreleasing*)parent

View File

@ -8,6 +8,6 @@
@property(nonatomic, readonly) NSInteger hoveredRow;
- (NSRect)iconRectForRow:(int)row;
- (NSRect)iconRectForRow:(NSInteger)row;
@end

View File

@ -56,7 +56,7 @@
return self.menu;
}
- (NSRect)iconRectForRow:(int)row
- (NSRect)iconRectForRow:(NSInteger)row
{
FileNameCell* cell = (FileNameCell*)[self preparedCellAtColumn:[self columnWithIdentifier:@"Name"] row:row];
NSRect iconRect = [cell imageRectForBounds:[self rectOfRow:row]];

View File

@ -18,7 +18,7 @@
@interface FilterBarController : NSViewController
@property(nonatomic, readonly) NSArray* searchStrings;
@property(nonatomic, readonly) NSArray<NSString*>* searchStrings;
- (instancetype)init;

View File

@ -36,7 +36,8 @@
- (instancetype)init
{
return (self = [super initWithNibName:@"FilterBar" bundle:nil]);
self = [super initWithNibName:@"FilterBar" bundle:nil];
return self;
}
- (void)awakeFromNib
@ -319,7 +320,7 @@
}
}
- (NSArray*)searchStrings
- (NSArray<NSString*>*)searchStrings
{
return [self.fSearchField.stringValue betterComponentsSeparatedByCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];
}

View File

@ -10,7 +10,7 @@
@interface GroupsController ()
@property(nonatomic, readonly) NSMutableArray* fGroups;
@property(nonatomic, readonly) NSMutableArray<NSMutableDictionary*>* fGroups;
- (void)saveGroups;

View File

@ -8,7 +8,7 @@
@interface InfoActivityViewController : NSViewController<InfoViewController>
- (void)setInfoForTorrents:(NSArray*)torrents;
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents;
- (void)updateInfo;
- (IBAction)setPiecesView:(id)sender;

View File

@ -16,7 +16,7 @@
@interface InfoActivityViewController ()
@property(nonatomic, copy) NSArray* fTorrents;
@property(nonatomic, copy) NSArray<Torrent*>* fTorrents;
@property(nonatomic) BOOL fSet;
@ -155,7 +155,7 @@
[NSNotificationCenter.defaultCenter removeObserver:self];
}
- (void)setInfoForTorrents:(NSArray*)torrents
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents
{
//don't check if it's the same in case the metadata changed
self.fTorrents = torrents;

View File

@ -9,10 +9,10 @@
@interface InfoFileViewController : NSViewController<InfoViewController>
@property(nonatomic, readonly) NSArray* quickLookURLs;
@property(nonatomic, readonly) NSArray<NSURL*>* quickLookURLs;
@property(nonatomic, readonly) BOOL canQuickLook;
- (void)setInfoForTorrents:(NSArray*)torrents;
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents;
- (void)updateInfo;
- (void)saveViewSize;

View File

@ -10,7 +10,7 @@
@interface InfoFileViewController ()
@property(nonatomic, copy) NSArray* fTorrents;
@property(nonatomic, copy) NSArray<Torrent*>* fTorrents;
@property(nonatomic) BOOL fSet;
@ -74,7 +74,7 @@
self.fCheckAllButton.frame = checkAllFrame;
}
- (void)setInfoForTorrents:(NSArray*)torrents
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents
{
//don't check if it's the same in case the metadata changed
self.fTorrents = torrents;
@ -125,7 +125,7 @@
[self.fFileController uncheckAll];
}
- (NSArray*)quickLookURLs
- (NSArray<NSURL*>*)quickLookURLs
{
FileOutlineView* fileOutlineView = self.fFileController.outlineView;
Torrent* torrent = self.fTorrents[0];

View File

@ -8,7 +8,7 @@
@interface InfoGeneralViewController : NSViewController<InfoViewController>
- (void)setInfoForTorrents:(NSArray*)torrents;
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents;
- (void)updateInfo;
- (void)revealDataFile:(id)sender;

View File

@ -8,7 +8,7 @@
@interface InfoGeneralViewController ()
@property(nonatomic, copy) NSArray* fTorrents;
@property(nonatomic, copy) NSArray<Torrent*>* fTorrents;
@property(nonatomic) BOOL fSet;
@ -112,7 +112,7 @@
}
}
- (void)setInfoForTorrents:(NSArray*)torrents
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents
{
//don't check if it's the same in case the metadata changed
self.fTorrents = torrents;

View File

@ -8,7 +8,7 @@
@interface InfoOptionsViewController : NSViewController<InfoViewController>
- (void)setInfoForTorrents:(NSArray*)torrents;
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents;
- (void)updateInfo;
- (void)updateOptions;

View File

@ -18,7 +18,7 @@
@interface InfoOptionsViewController ()
@property(nonatomic, copy) NSArray* fTorrents;
@property(nonatomic, copy) NSArray<Torrent*>* fTorrents;
@property(nonatomic) BOOL fSet;
@ -86,7 +86,7 @@
[NSNotificationCenter.defaultCenter removeObserver:self];
}
- (void)setInfoForTorrents:(NSArray*)torrents
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents
{
//don't check if it's the same in case the metadata changed
self.fTorrents = torrents;
@ -306,7 +306,7 @@
while ((torrent = [enumerator nextObject]) && priority != INVALID)
{
if (priority != INVALID && priority != torrent.priority)
if (priority != torrent.priority)
{
priority = INVALID;
}

View File

@ -8,7 +8,7 @@
@interface InfoPeersViewController : NSViewController<InfoViewController>
- (void)setInfoForTorrents:(NSArray*)torrents;
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents;
- (void)updateInfo;
- (void)saveViewSize;

View File

@ -17,12 +17,12 @@
@interface InfoPeersViewController ()<CAAnimationDelegate>
@property(nonatomic, copy) NSArray* fTorrents;
@property(nonatomic, copy) NSArray<Torrent*>* fTorrents;
@property(nonatomic) BOOL fSet;
@property(nonatomic) NSMutableArray* fPeers;
@property(nonatomic) NSMutableArray* fWebSeeds;
@property(nonatomic) NSMutableArray<NSDictionary*>* fPeers;
@property(nonatomic) NSMutableArray<NSDictionary*>* fWebSeeds;
@property(nonatomic) IBOutlet NSTableView* fPeerTable;
@property(nonatomic) IBOutlet WebSeedTableView* fWebSeedTable;
@ -31,7 +31,7 @@
@property(nonatomic) CGFloat fViewTopMargin;
@property(nonatomic) IBOutlet NSLayoutConstraint* fWebSeedTableTopConstraint;
@property(nonatomic, readonly) NSArray* peerSortDescriptors;
@property(nonatomic, readonly) NSArray<NSSortDescriptor*>* peerSortDescriptors;
- (void)setupInfo;
@ -96,7 +96,7 @@
}
#warning subclass?
- (void)setInfoForTorrents:(NSArray*)torrents
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents
{
//don't check if it's the same in case the metadata changed
self.fTorrents = torrents;
@ -573,7 +573,7 @@
(animate ? [self.fWebSeedTableTopConstraint animator] : self.fWebSeedTableTopConstraint).constant = webSeedTableTopMargin;
}
- (NSArray*)peerSortDescriptors
- (NSArray<NSSortDescriptor*>*)peerSortDescriptors
{
NSMutableArray* descriptors = [NSMutableArray arrayWithCapacity:2];

View File

@ -8,7 +8,7 @@
@interface InfoTrackersViewController : NSViewController<InfoViewController>
- (void)setInfoForTorrents:(NSArray*)torrents;
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents;
- (void)updateInfo;
- (void)saveViewSize;

View File

@ -16,7 +16,7 @@
@interface InfoTrackersViewController ()
@property(nonatomic, copy) NSArray* fTorrents;
@property(nonatomic, copy) NSArray<Torrent*>* fTorrents;
@property(nonatomic) BOOL fSet;
@ -64,7 +64,7 @@
}
}
- (void)setInfoForTorrents:(NSArray*)torrents
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents
{
//don't check if it's the same in case the metadata changed
self.fTorrents = torrents;
@ -91,7 +91,7 @@
if (self.fTorrents.count == 1)
{
self.fTrackers = ((Torrent*)self.fTorrents[0]).allTrackerStats;
self.fTrackers = self.fTorrents[0].allTrackerStats;
}
else
{
@ -120,7 +120,7 @@
NSIndexSet* addedIndexes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(self.fTrackers.count - 2, 2)];
NSArray* tierAndTrackerBeingAdded = [self.fTrackers objectsAtIndexes:addedIndexes];
self.fTrackers = ((Torrent*)self.fTorrents[0]).allTrackerStats;
self.fTrackers = self.fTorrents[0].allTrackerStats;
[self.fTrackers addObjectsFromArray:tierAndTrackerBeingAdded];
self.fTrackerTable.trackers = self.fTrackers;

View File

@ -4,9 +4,11 @@
#import <Cocoa/Cocoa.h>
@class Torrent;
@protocol InfoViewController
- (void)setInfoForTorrents:(NSArray*)torrents;
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents;
- (void)updateInfo;
@optional

View File

@ -5,12 +5,14 @@
#import <Cocoa/Cocoa.h>
#import <Quartz/Quartz.h>
@class Torrent;
@interface InfoWindowController : NSWindowController
@property(nonatomic, readonly) NSArray* quickLookURLs;
@property(nonatomic, readonly) NSArray<NSURL*>* quickLookURLs;
@property(nonatomic, readonly) BOOL canQuickLook;
- (void)setInfoForTorrents:(NSArray*)torrents;
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents;
- (void)updateInfoStats;
- (void)updateOptions;

View File

@ -37,7 +37,7 @@ typedef NS_ENUM(unsigned int, tabTag) {
@interface InfoWindowController ()
@property(nonatomic, copy) NSArray* fTorrents;
@property(nonatomic, copy) NSArray<Torrent*>* fTorrents;
@property(nonatomic) CGFloat fMinWindowWidth;
@ -168,7 +168,7 @@ typedef NS_ENUM(unsigned int, tabTag) {
}
}
- (void)setInfoForTorrents:(NSArray*)torrents
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents
{
if (self.fTorrents && [self.fTorrents isEqualToArray:torrents])
{
@ -403,7 +403,7 @@ typedef NS_ENUM(unsigned int, tabTag) {
[self.fOptionsViewController updateOptions];
}
- (NSArray*)quickLookURLs
- (NSArray<NSURL*>*)quickLookURLs
{
return self.fFileViewController.quickLookURLs;
}

View File

@ -28,10 +28,10 @@
@property(nonatomic) IBOutlet NSButton* fClearButton;
@property(nonatomic) IBOutlet NSSearchField* fFilterField;
@property(nonatomic) NSMutableArray* fMessages;
@property(nonatomic) NSMutableArray* fDisplayedMessages;
@property(nonatomic) NSMutableArray<NSDictionary*>* fMessages;
@property(nonatomic) NSMutableArray<NSDictionary*>* fDisplayedMessages;
@property(nonatomic, copy) NSDictionary* fAttributes;
@property(nonatomic, copy) NSDictionary<NSAttributedStringKey, id>* fAttributes;
@property(nonatomic) NSTimer* fTimer;
@ -487,11 +487,10 @@
NSInteger const level = [NSUserDefaults.standardUserDefaults integerForKey:@"MessageLevel"];
NSString* filterString = self.fFilterField.stringValue;
NSIndexSet* indexes = [self.fMessages indexesOfObjectsWithOptions:NSEnumerationConcurrent
passingTest:^BOOL(id message, NSUInteger idx, BOOL* stop) {
return [((NSDictionary*)message)[@"Level"] integerValue] <= level &&
[self shouldIncludeMessageForFilter:filterString message:message];
}];
NSIndexSet* indexes = [self.fMessages
indexesOfObjectsWithOptions:NSEnumerationConcurrent passingTest:^BOOL(NSDictionary* message, NSUInteger idx, BOOL* stop) {
return [message[@"Level"] integerValue] <= level && [self shouldIncludeMessageForFilter:filterString message:message];
}];
NSArray* tempMessages = [[self.fMessages objectsAtIndexes:indexes] sortedArrayUsingDescriptors:self.fMessageTable.sortDescriptors];

View File

@ -2,7 +2,7 @@
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
@interface NSString (NSStringAdditions)

View File

@ -128,7 +128,7 @@
return [self compare:string options:comparisonOptions range:NSMakeRange(0, self.length) locale:NSLocale.currentLocale];
}
- (NSArray*)betterComponentsSeparatedByCharactersInSet:(NSCharacterSet*)separators
- (NSArray<NSString*>*)betterComponentsSeparatedByCharactersInSet:(NSCharacterSet*)separators
{
NSMutableArray* components = [NSMutableArray array];

View File

@ -2,7 +2,7 @@
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
typedef NS_ENUM(unsigned int, port_status_t) { //
PORT_STATUS_CHECKING,

View File

@ -8,7 +8,7 @@
@interface PrefsController : NSWindowController<NSToolbarDelegate>
@property(nonatomic, readonly) NSArray* sounds;
@property(nonatomic, readonly) NSArray<NSString*>* sounds;
+ (NSInteger)dateToTimeSum:(NSDate*)date;

View File

@ -97,7 +97,7 @@
@property(nonatomic) IBOutlet NSTextField* fRPCPortField;
@property(nonatomic) IBOutlet NSTextField* fRPCPasswordField;
@property(nonatomic) IBOutlet NSTableView* fRPCWhitelistTable;
@property(nonatomic, readonly) NSMutableArray* fRPCWhitelistArray;
@property(nonatomic, readonly) NSMutableArray<NSString*>* fRPCWhitelistArray;
@property(nonatomic) IBOutlet NSSegmentedControl* fRPCAddRemoveControl;
@property(nonatomic, copy) NSString* fRPCPassword;
@ -482,7 +482,7 @@
self.fPortChecker = nil;
}
- (NSArray*)sounds
- (NSArray<NSString*>*)sounds
{
NSMutableArray* sounds = [NSMutableArray array];
@ -843,7 +843,7 @@
- (void)setQueueNumber:(id)sender
{
NSInteger const number = [sender intValue];
int const number = [sender intValue];
BOOL const seed = sender == self.fQueueSeedField;
[self.fDefaults setInteger:number forKey:seed ? @"QueueSeedNumber" : @"QueueDownloadNumber"];
@ -861,7 +861,7 @@
- (void)setStalledMinutes:(id)sender
{
NSInteger const min = [sender intValue];
int const min = [sender intValue];
[self.fDefaults setInteger:min forKey:@"StalledMinutes"];
tr_sessionSetQueueStalledMinutes(self.fHandle, min);
@ -1183,7 +1183,7 @@
[self.fRPCWhitelistArray addObject:@""];
[self.fRPCWhitelistTable reloadData];
int const row = self.fRPCWhitelistArray.count - 1;
NSUInteger const row = self.fRPCWhitelistArray.count - 1;
[self.fRPCWhitelistTable selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
[self.fRPCWhitelistTable editColumn:0 row:row withEvent:nil select:YES];
}

View File

@ -1,3 +1,4 @@
#import <AppKit/AppKit.h>
#import <QuickLook/QuickLook.h>
#include <string>

View File

@ -3,13 +3,13 @@
// License text can be found in the licenses/ folder.
// Created by Mitchell Livingston on 1/10/14.
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
@interface ShareTorrentFileHelper : NSObject
@property(nonatomic, class, readonly) ShareTorrentFileHelper* sharedHelper;
@property(nonatomic, readonly) NSArray* shareTorrentURLs;
@property(nonatomic, readonly) NSArray* menuItems;
@property(nonatomic, readonly) NSArray<NSURL*>* shareTorrentURLs;
@property(nonatomic, readonly) NSArray<NSMenuItem*>* menuItems;
@end

View File

@ -19,7 +19,7 @@
return helper;
}
- (NSArray*)shareTorrentURLs
- (NSArray<NSURL*>*)shareTorrentURLs
{
NSArray* torrents = ((Controller*)NSApp.delegate).selectedTorrents;
NSMutableArray* fileURLs = [NSMutableArray arrayWithCapacity:torrents.count];
@ -34,7 +34,7 @@
return fileURLs;
}
- (NSArray*)menuItems
- (NSArray<NSMenuItem*>*)menuItems
{
NSArray* services = [NSSharingService sharingServicesForItems:self.shareTorrentURLs];
NSMutableArray* items = [NSMutableArray arrayWithCapacity:services.count];

View File

@ -93,7 +93,7 @@ typedef NS_ENUM(unsigned int, TorrentDeterminationType) {
@property(nonatomic, readonly) uint64_t sizeLeft;
@property(nonatomic, readonly) NSMutableArray* allTrackerStats;
@property(nonatomic, readonly) NSArray* allTrackersFlat; //used by GroupRules
@property(nonatomic, readonly) NSArray<NSString*>* allTrackersFlat; //used by GroupRules
- (BOOL)addTrackerToNewTier:(NSString*)tracker;
- (void)removeTrackers:(NSSet*)trackers;
@ -133,10 +133,10 @@ typedef NS_ENUM(unsigned int, TorrentDeterminationType) {
@property(nonatomic, getter=isAnyErrorOrWarning, readonly) BOOL anyErrorOrWarning;
@property(nonatomic, readonly) NSString* errorMessage;
@property(nonatomic, readonly) NSArray* peers;
@property(nonatomic, readonly) NSArray<NSDictionary*>* peers;
@property(nonatomic, readonly) NSUInteger webSeedCount;
@property(nonatomic, readonly) NSArray* webSeeds;
@property(nonatomic, readonly) NSArray<NSDictionary*>* webSeeds;
@property(nonatomic, readonly) NSString* progressString;
@property(nonatomic, readonly) NSString* statusString;
@ -172,8 +172,8 @@ typedef NS_ENUM(unsigned int, TorrentDeterminationType) {
@property(nonatomic, readonly) NSInteger groupOrderValue;
- (void)checkGroupValueForRemoval:(NSNotification*)notification;
@property(nonatomic, readonly) NSArray* fileList;
@property(nonatomic, readonly) NSArray* flatFileList;
@property(nonatomic, readonly) NSArray<FileListNode*>* fileList;
@property(nonatomic, readonly) NSArray<FileListNode*>* flatFileList;
@property(nonatomic, readonly) NSInteger fileCount;
//methods require fileStats to have been updated recently to be accurate

View File

@ -30,8 +30,8 @@
@property(nonatomic) NSImage* fIcon;
@property(nonatomic, copy) NSArray* fileList;
@property(nonatomic, copy) NSArray* flatFileList;
@property(nonatomic, copy) NSArray<FileListNode*>* fileList;
@property(nonatomic, copy) NSArray<FileListNode*>* flatFileList;
@property(nonatomic, copy) NSIndexSet* fPreviousFinishedIndexes;
@property(nonatomic) NSDate* fPreviousFinishedIndexesDate;
@ -61,8 +61,8 @@
forParent:(FileListNode*)parent
fileSize:(uint64_t)size
index:(NSInteger)index
flatList:(NSMutableArray*)flatFileList;
- (void)sortFileList:(NSMutableArray*)fileNodes;
flatList:(NSMutableArray<FileListNode*>*)flatFileList;
- (void)sortFileList:(NSMutableArray<FileListNode*>*)fileNodes;
- (void)startQueue;
- (void)completenessChange:(tr_completeness)status wasRunning:(BOOL)wasRunning;
@ -70,7 +70,7 @@
- (void)idleLimitHit;
- (void)metadataRetrieved;
- (void)renameFinished:(BOOL)success
nodes:(NSArray*)nodes
nodes:(NSArray<FileListNode*>*)nodes
completionHandler:(void (^)(BOOL))completionHandler
oldPath:(NSString*)oldPath
newName:(NSString*)newName;
@ -697,7 +697,7 @@ bool trashDataFile(char const* filename, tr_error** error)
return trackers;
}
- (NSArray*)allTrackersFlat
- (NSArray<NSString*>*)allTrackersFlat
{
auto const n = tr_torrentTrackerCount(self.fHandle);
NSMutableArray* allTrackers = [NSMutableArray arrayWithCapacity:n];
@ -983,7 +983,7 @@ bool trashDataFile(char const* filename, tr_error** error)
return error;
}
- (NSArray*)peers
- (NSArray<NSDictionary*>*)peers
{
int totalPeers;
tr_peer_stat* peers = tr_torrentPeers(self.fHandle, &totalPeers);
@ -1028,7 +1028,7 @@ bool trashDataFile(char const* filename, tr_error** error)
return tr_torrentWebseedCount(self.fHandle);
}
- (NSArray*)webSeeds
- (NSArray<NSDictionary*>*)webSeeds
{
NSUInteger n = tr_torrentWebseedCount(self.fHandle);
NSMutableArray* webSeeds = [NSMutableArray arrayWithCapacity:n];
@ -1897,12 +1897,12 @@ bool trashDataFile(char const* filename, tr_error** error)
}
}
- (void)insertPathForComponents:(NSArray*)components
- (void)insertPathForComponents:(NSArray<NSString*>*)components
withComponentIndex:(NSUInteger)componentIndex
forParent:(FileListNode*)parent
fileSize:(uint64_t)size
index:(NSInteger)index
flatList:(NSMutableArray*)flatFileList
flatList:(NSMutableArray<FileListNode*>*)flatFileList
{
NSParameterAssert(components.count > 0);
NSParameterAssert(componentIndex < components.count);
@ -1951,7 +1951,7 @@ bool trashDataFile(char const* filename, tr_error** error)
}
}
- (void)sortFileList:(NSMutableArray*)fileNodes
- (void)sortFileList:(NSMutableArray<FileListNode*>*)fileNodes
{
NSSortDescriptor* descriptor = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES
selector:@selector(localizedStandardCompare:)];
@ -2042,7 +2042,7 @@ bool trashDataFile(char const* filename, tr_error** error)
}
- (void)renameFinished:(BOOL)success
nodes:(NSArray*)nodes
nodes:(NSArray<FileListNode*>*)nodes
completionHandler:(void (^)(BOOL))completionHandler
oldPath:(NSString*)oldPath
newName:(NSString*)newName

View File

@ -4,13 +4,15 @@
#import <Cocoa/Cocoa.h>
@class Torrent;
@interface TorrentGroup : NSObject
- (instancetype)initWithGroup:(NSInteger)group;
@property(nonatomic, readonly) NSInteger groupIndex;
@property(nonatomic, readonly) NSInteger groupOrderValue;
@property(nonatomic, readonly) NSMutableArray* torrents;
@property(nonatomic, readonly) NSMutableArray<Torrent*>* torrents;
@property(nonatomic, readonly) CGFloat ratio;
@property(nonatomic, readonly) CGFloat uploadRate;

View File

@ -25,7 +25,7 @@
- (void)selectValues:(NSArray*)values;
@property(nonatomic, readonly) NSArray* selectedValues;
@property(nonatomic, readonly) NSArray* selectedTorrents;
@property(nonatomic, readonly) NSArray<Torrent*>* selectedTorrents;
- (NSRect)iconRectForRow:(NSInteger)row;

View File

@ -561,7 +561,7 @@
return values;
}
- (NSArray*)selectedTorrents
- (NSArray<Torrent*>*)selectedTorrents
{
NSIndexSet* selectedIndexes = self.selectedRowIndexes;
NSMutableArray* torrents = [NSMutableArray arrayWithCapacity:selectedIndexes.count]; //take a shot at guessing capacity

View File

@ -6,7 +6,7 @@
@interface WebSeedTableView : NSTableView
@property(nonatomic, weak) NSArray* webSeeds;
@property(nonatomic, weak) NSArray<NSDictionary*>* webSeeds;
- (void)copy:(id)sender;