diff --git a/PlayerPRO Player/CurrentlyPlayingIndex.swift b/PlayerPRO Player/CurrentlyPlayingIndex.swift index 0fc9bbf9..fdc1fdb9 100644 --- a/PlayerPRO Player/CurrentlyPlayingIndex.swift +++ b/PlayerPRO Player/CurrentlyPlayingIndex.swift @@ -13,10 +13,17 @@ struct CurrentlyPlayingIndex: CustomDebugStringConvertible, CustomStringConverti var playbackURL: URL? = nil var description: String { - return "Index: \(index) URL: \(playbackURL!.relativePath)" + return "Index: \(index) URL: \(playbackURL?.relativePath ?? "none")" } var debugDescription: String { - return "Index: \(index) URL: '\(playbackURL)' URL Path: \(playbackURL!.path)" + let urlDes: String + if let playURL = playbackURL { + urlDes = String(describing: playURL) + } else { + urlDes = "none" + } + + return "Index: \(index) URL: '\(urlDes)' URL Path: \(playbackURL?.path ?? "none")" } } diff --git a/PlayerPRO Player/PlayerAppDelegate.swift b/PlayerPRO Player/PlayerAppDelegate.swift index 6cff2512..a02e067e 100644 --- a/PlayerPRO Player/PlayerAppDelegate.swift +++ b/PlayerPRO Player/PlayerAppDelegate.swift @@ -246,6 +246,7 @@ class PlayerAppDelegate: NSObject, NSApplicationDelegate, NSTableViewDelegate, N } func addMusicToMusicList(_ theURL: URL, loadIfPreferencesAllow load: Bool = true) { + // clear sort descriptors, so added files don't get sorted incorrectly. tableView.sortDescriptors = [] willChangeValue(forKey: kMusicListKVO) let okayMusic = musicList.addMusicURL(theURL, force: false) @@ -261,8 +262,10 @@ class PlayerAppDelegate: NSObject, NSApplicationDelegate, NSTableViewDelegate, N similarAlert.informativeText = "There is already a tracker file that points to the added file. Do you still wish to add it?"; similarAlert.addButton(withTitle: "Add") - let cancelButton = similarAlert.addButton(withTitle: "Cancel") - cancelButton.keyEquivalent = PPEscapeValue; + do { + let cancelButton = similarAlert.addButton(withTitle: "Cancel") + cancelButton.keyEquivalent = "\u{1b}" //escape + } similarAlert.addButton(withTitle: "Load Existing") diff --git a/Shared/PPTimeFormatter.m b/Shared/PPTimeFormatter.m index 98bbccce..ea3a433b 100644 --- a/Shared/PPTimeFormatter.m +++ b/Shared/PPTimeFormatter.m @@ -6,9 +6,9 @@ // // +#include #import "PPTimeFormatter.h" #import -#import @implementation PPTimeFormatter @@ -16,13 +16,15 @@ - (NSString *)stringForObjectValue:(id)obj { if ([obj isKindOfClass:[NSNumber class]] ) { NSInteger theVal = [obj integerValue]; - int seconds = (theVal/60) % 60; - int minutes = (theVal/(60 * 60)) % 60; - if (theVal / (60*60*60) > 0) { - int hours = (int)(theVal/(60 * 60 * 60)); - return [NSString stringWithFormat:@"%d:%02d:%02d", hours, minutes, seconds]; + NSInteger fullVal = labs(theVal); + BOOL isNeg = theVal < 0; + int seconds = (fullVal/60) % 60; + int minutes = (fullVal/(60 * 60)) % 60; + if (fullVal / (60*60*60) > 0) { + int hours = (int)(fullVal/(60 * 60 * 60)); + return [NSString stringWithFormat:@"%s%d:%02d:%02d", isNeg ? "-": "", hours, minutes, seconds]; } else { - return [NSString stringWithFormat:@"%d:%02d", minutes, seconds]; + return [NSString stringWithFormat:@"%s%d:%02d", isNeg ? "-": "", minutes, seconds]; } } else return nil; } diff --git a/Shared/UserDefaultKeys.h b/Shared/UserDefaultKeys.h index ed9bcb79..91d81d6c 100644 --- a/Shared/UserDefaultKeys.h +++ b/Shared/UserDefaultKeys.h @@ -213,7 +213,6 @@ extern NSString * const PPCETrackHeight; #pragma mark Misc./other extern NSString * const PPDoubleDash; extern NSString * const kMusicListKVO; -#define PPEscapeValue @"\e" NS_ASSUME_NONNULL_END