Skip to content

Commit

Permalink
fix: unexpected force unwrapping, #49
Browse files Browse the repository at this point in the history
  • Loading branch information
ddddxxx committed May 21, 2017
1 parent 11643b3 commit 363b999
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 66 deletions.
6 changes: 3 additions & 3 deletions LyricsX/MediaPlayer/Spotify.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ extension SpotifyEPlS {
extension SpotifyTrack {
var track: MusicTrack? {
guard let id = id?() as? String,
let name = name as String?,
let album = album as String?,
let artist = artist as String? else {
let name = name as? String,
let album = album as? String,
let artist = artist as? String else {
return nil
}

Expand Down
14 changes: 7 additions & 7 deletions LyricsX/MediaPlayer/SpotifyBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ import ScriptingBridge
// The name of the application.
@objc optional var frontmost: Bool {get}
// Is this the frontmost (active) application?
@objc optional var version: NSString {get}
@objc optional var version: NSString? {get}
// The version of the application.
}
extension SBApplication: SpotifyApplication{}


// A Spotify track.
@objc protocol SpotifyTrack {
@objc optional var artist: NSString {get}
@objc optional var artist: NSString? {get}
// The artist of the track.
@objc optional var album: NSString {get}
@objc optional var album: NSString? {get}
// The album of the track.
@objc optional var discNumber: NSInteger {get}
// The disc number of the track.
Expand All @@ -97,14 +97,14 @@ extension SBApplication: SpotifyApplication{}
// How popular is this track? 0-100
@objc optional func id() -> NSString?
// The ID of the item.
@objc optional var name: NSString {get}
@objc optional var name: NSString? {get}
// The name of the track.
@objc optional var artworkUrl: NSString {get}
@objc optional var artworkUrl: NSString? {get}
// The URL of the track%apos @objc optional var artwork: NSImage {get}
// The property is deprecated and will never be set. Use the "artwork url" instead.
@objc optional var albumArtist: NSString {get}
@objc optional var albumArtist: NSString? {get}
// That album artist of the track.
@objc optional var spotifyUrl: NSString {get set}
@objc optional var spotifyUrl: NSString? {get set}
// The URL of the track.
}
extension SBObject: SpotifyTrack{}
6 changes: 3 additions & 3 deletions LyricsX/MediaPlayer/Vox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ extension VoxApplication {
}
var track: MusicTrack? {
guard let id = uniqueID as? String,
let name = track as String?,
let album = album as String?,
let artist = artist as String? else {
let name = track as? String,
let album = album as? String,
let artist = artist as? String else {
return nil
}
return MusicTrack(id: id, name: name, album: album, artist: artist, duration: totalTime as TimeInterval?)
Expand Down
14 changes: 7 additions & 7 deletions LyricsX/MediaPlayer/VoxBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import ScriptingBridge
*/
// The application"s top level scripting object.
@objc protocol VoxApplication {
@objc optional var name: NSString {get}
@objc optional var name: NSString? {get}
// The name of the application.
@objc optional var frontmost: Bool {get}
// Is this the frontmost (active) application?
@objc optional var version: NSString {get}
@objc optional var version: NSString? {get}
// The version of the application.
@objc optional func quit()
// Quit an application.
Expand Down Expand Up @@ -76,15 +76,15 @@ import ScriptingBridge
// Current track artwork as an image.
@objc optional var playerState: NSInteger {get}
// Player state (playing = 1, paused = 0)
@objc optional var track: NSString {get}
@objc optional var track: NSString? {get}
// Current track title.
@objc optional var trackUrl: NSString {get}
@objc optional var trackUrl: NSString? {get}
// Current track URL.
@objc optional var artist: NSString {get}
@objc optional var artist: NSString? {get}
// Current track artist.
@objc optional var albumArtist: NSString {get}
@objc optional var albumArtist: NSString? {get}
// Current track album artist.
@objc optional var album: NSString {get}
@objc optional var album: NSString? {get}
// Current track album.
@objc optional var uniqueID: NSString? {get}
// Unique identifier for the current track.
Expand Down
6 changes: 3 additions & 3 deletions LyricsX/MediaPlayer/iTunes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class iTunes: MusicPlayer {

var currentLyrics: String? {
get {
return _iTunes.currentTrack?.lyrics as String?
return _iTunes.currentTrack?.lyrics as? String
}
set {
(_iTunes.currentTrack as? SBObject)?.setValue(newValue ?? "", forKey: "lyrics")
Expand Down Expand Up @@ -101,8 +101,8 @@ extension iTunesTrack {
var track: MusicTrack? {
guard let id = stringID,
let name = name as? String,
let album = album as String?,
let artist = artist as String? else {
let album = album as? String,
let artist = artist as? String else {
return nil
}

Expand Down
86 changes: 43 additions & 43 deletions LyricsX/MediaPlayer/iTunesBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ import ScriptingBridge
// the currently selected equalizer preset
@objc optional var currentPlaylist: iTunesPlaylist {get}
// the playlist containing the currently targeted track
@objc optional var currentStreamTitle: NSString {get}
@objc optional var currentStreamTitle: NSString? {get}
// the name of the current song in the playing stream (provided by streaming server)
@objc optional var currentStreamURL: NSString {get}
@objc optional var currentStreamURL: NSString? {get}
// the URL of the playing stream or streaming web site (provided by streaming server)
@objc optional var currentTrack: iTunesTrack {get}
// the current targeted track
Expand All @@ -213,7 +213,7 @@ import ScriptingBridge
// is iTunes the frontmost application?
@objc optional var fullScreen: Bool {get set}
// are visuals displayed using the entire screen?
@objc optional var name: NSString {get}
@objc optional var name: NSString? {get}
// the name of the application
@objc optional var mute: Bool {get set}
// has the sound output been muted?
Expand All @@ -231,7 +231,7 @@ import ScriptingBridge
// the playback repeat mode
@objc optional var soundVolume: NSInteger {get set}
// the sound output volume (0 = minimum, 100 = maximum)
@objc optional var version: NSString {get}
@objc optional var version: NSString? {get}
// the version of iTunes
@objc optional var visualsEnabled: Bool {get set}
// are visuals currently being displayed?
Expand Down Expand Up @@ -293,7 +293,7 @@ extension SBApplication: iTunesApplication{}
// The index of the item in internal application order.
@objc optional var name: NSString? {get set}
// the name of the item
@objc optional var persistentID: NSString {get}
@objc optional var persistentID: NSString? {get}
// the id of the item as a hexadecimal string. This id does not change over time.
@objc optional var properties: NSDictionary {get set}
// every property of the item
Expand All @@ -313,7 +313,7 @@ extension SBObject: iTunesItem{}
// is the device currently available?
@objc optional var kind: iTunesEAPD {get}
// the kind of the device
@objc optional var networkAddress: NSString {get}
@objc optional var networkAddress: NSString? {get}
// the network (MAC) address of the device
@objc optional func protected() -> Bool
// is the device password- or passcode-protected?
Expand All @@ -333,7 +333,7 @@ extension SBObject: iTunesAirPlayDevice{}
@objc protocol iTunesArtwork: iTunesItem {
@objc optional var data: NSImage {get set}
// data for this artwork, in the form of a picture
@objc optional var objectDescription: NSString {get set}
@objc optional var objectDescription: NSString? {get set}
// description of artwork as a string
@objc optional var downloaded: Bool {get}
// was this artwork downloaded by iTunes?
Expand All @@ -349,7 +349,7 @@ extension SBObject: iTunesArtwork{}

// converts a track to a specific file format
@objc protocol iTunesEncoder: iTunesItem {
@objc optional var format: NSString {get}
@objc optional var format: NSString? {get}
// the data format created by the encoder
}
extension SBObject: iTunesEncoder{}
Expand Down Expand Up @@ -391,13 +391,13 @@ extension SBObject: iTunesEQPreset{}
@objc protocol iTunesPlaylist: iTunesItem {
@objc optional func tracks() -> [iTunesTrack]
@objc optional func artworks() -> [iTunesArtwork]
@objc optional var objectDescription: NSString {get set}
@objc optional var objectDescription: NSString? {get set}
// the description of the playlist
@objc optional var disliked: Bool {get set}
// is this playlist disliked?
@objc optional var duration: NSInteger {get}
// the total length of all songs (in seconds)
@objc optional var name: NSString {get set}
@objc optional var name: NSString? {get set}
// the name of the playlist
@objc optional var loved: Bool {get set}
// is this playlist loved?
Expand All @@ -409,7 +409,7 @@ extension SBObject: iTunesEQPreset{}
@objc optional var songRepeat: iTunesERpt {get set}
// playback repeat mode (obsolete @objc optional var specialKind: iTunesESpK {get}
// special playlist kind
@objc optional var time: NSString {get}
@objc optional var time: NSString? {get}
// the length of all songs in MM:SS format
@objc optional var visible: Bool {get}
// is this playlist visible in the Source list?
Expand All @@ -424,17 +424,17 @@ extension SBObject: iTunesPlaylist{}
// a playlist representing an audio CD
@objc protocol iTunesAudioCDPlaylist: iTunesPlaylist {
@objc optional func audioCDTracks() -> [iTunesAudioCDTrack]
@objc optional var artist: NSString {get set}
@objc optional var artist: NSString? {get set}
// the artist of the CD
@objc optional var compilation: Bool {get set}
// is this CD a compilation album?
@objc optional var composer: NSString {get set}
@objc optional var composer: NSString? {get set}
// the composer of the CD
@objc optional var discCount: NSInteger {get set}
// the total number of discs in this CD’s album
@objc optional var discNumber: NSInteger {get set}
// the index of this CD disc in the source album
@objc optional var genre: NSString {get set}
@objc optional var genre: NSString? {get set}
// the genre of the CD
@objc optional var year: NSInteger {get set}
// the year the album was recorded/released
Expand Down Expand Up @@ -490,9 +490,9 @@ extension SBObject: iTunesSubscriptionPlaylist{}
// playable audio source
@objc protocol iTunesTrack: iTunesItem {
@objc optional func artworks() -> [iTunesArtwork]
@objc optional var album: NSString {get set}
@objc optional var album: NSString? {get set}
// the album name of the track
@objc optional var albumArtist: NSString {get set}
@objc optional var albumArtist: NSString? {get set}
// the album artist of the track
@objc optional var albumDisliked: Bool {get set}
// is the album for this track disliked?
Expand All @@ -502,7 +502,7 @@ extension SBObject: iTunesSubscriptionPlaylist{}
// the rating of the album for this track (0 to 100)
@objc optional var albumRatingKind: iTunesERtK {get}
// the rating kind of the album rating for this track
@objc optional var artist: NSString {get set}
@objc optional var artist: NSString? {get set}
// the artist/source of the track
@objc optional var bitRate: NSInteger {get}
// the bit rate of the track (in kbps)
Expand All @@ -512,62 +512,62 @@ extension SBObject: iTunesSubscriptionPlaylist{}
// is the playback position for this track remembered?
@objc optional var bpm: NSInteger {get set}
// the tempo of this track in beats per minute
@objc optional var category: NSString {get set}
@objc optional var category: NSString? {get set}
// the category of the track
@objc optional var cloudStatus: iTunesEClS {get}
// the iCloud status of the track
@objc optional var comment: NSString {get set}
@objc optional var comment: NSString? {get set}
// freeform notes about the track
@objc optional var compilation: Bool {get set}
// is this track from a compilation album?
@objc optional var composer: NSString {get set}
@objc optional var composer: NSString? {get set}
// the composer of the track
@objc optional var databaseID: NSInteger {get}
// the common, unique ID for this track. If two tracks in different playlists have the same database ID, they are sharing the same data.
@objc optional var dateAdded: NSDate {get}
// the date the track was added to the playlist
@objc optional var objectDescription: NSString {get set}
@objc optional var objectDescription: NSString? {get set}
// the description of the track
@objc optional var discCount: NSInteger {get set}
// the total number of discs in the source album
@objc optional var discNumber: NSInteger {get set}
// the index of the disc containing this track on the source album
@objc optional var disliked: Bool {get set}
// is this track disliked?
@objc optional var downloaderAppleID: NSString {get}
@objc optional var downloaderAppleID: NSString? {get}
// the Apple ID of the person who downloaded this track
@objc optional var downloaderName: NSString {get}
@objc optional var downloaderName: NSString? {get}
// the name of the person who downloaded this track
@objc optional var duration: CDouble {get}
// the length of the track in seconds
@objc optional var enabled: Bool {get set}
// is this track checked for playback?
@objc optional var episodeID: NSString {get set}
@objc optional var episodeID: NSString? {get set}
// the episode ID of the track
@objc optional var episodeNumber: NSInteger {get set}
// the episode number of the track
@objc optional var EQ: NSString {get set}
@objc optional var EQ: NSString? {get set}
// the name of the EQ preset of the track
@objc optional var finish: CDouble {get set}
// the stop time of the track in seconds
@objc optional var gapless: Bool {get set}
// is this track from a gapless album?
@objc optional var genre: NSString {get set}
@objc optional var genre: NSString? {get set}
// the music/audio genre (category) of the track
@objc optional var grouping: NSString {get set}
@objc optional var grouping: NSString? {get set}
// the grouping (piece) of the track. Generally used to denote movements within a classical work.
@objc optional var kind: NSString {get}
@objc optional var kind: NSString? {get}
// a text description of the track
@objc optional var longDescription: NSString {get set}
@objc optional var longDescription: NSString? {get set}
@objc optional var loved: Bool {get set}
// is this track loved?
@objc optional var lyrics: NSString {get set}
@objc optional var lyrics: NSString? {get set}
// the lyrics of the track
@objc optional var mediaKind: iTunesEMdK {get set}
// the media kind of the track
@objc optional var modificationDate: NSDate {get}
// the modification date of the content of this track
@objc optional var movement: NSString {get set}
@objc optional var movement: NSString? {get set}
// the movement name of the track
@objc optional var movementCount: NSInteger {get set}
// the total number of movements in the work
Expand All @@ -577,9 +577,9 @@ extension SBObject: iTunesSubscriptionPlaylist{}
// number of times this track has been played
@objc optional var playedDate: NSDate {get set}
// the date and time this track was last played
@objc optional var purchaserAppleID: NSString {get}
@objc optional var purchaserAppleID: NSString? {get}
// the Apple ID of the person who purchased this track
@objc optional var purchaserName: NSString {get}
@objc optional var purchaserName: NSString? {get}
// the name of the person who purchased this track
@objc optional var rating: NSInteger {get set}
// the rating of this track (0 to 100)
Expand All @@ -597,25 +597,25 @@ extension SBObject: iTunesSubscriptionPlaylist{}
// number of times this track has been skipped
@objc optional var skippedDate: NSDate {get set}
// the date and time this track was last skipped
@objc optional var show: NSString {get set}
@objc optional var show: NSString? {get set}
// the show name of the track
@objc optional var sortAlbum: NSString {get set}
@objc optional var sortAlbum: NSString? {get set}
// override string to use for the track when sorting by album
@objc optional var sortArtist: NSString {get set}
@objc optional var sortArtist: NSString? {get set}
// override string to use for the track when sorting by artist
@objc optional var sortAlbumArtist: NSString {get set}
@objc optional var sortAlbumArtist: NSString? {get set}
// override string to use for the track when sorting by album artist
@objc optional var sortName: NSString {get set}
@objc optional var sortName: NSString? {get set}
// override string to use for the track when sorting by name
@objc optional var sortComposer: NSString {get set}
@objc optional var sortComposer: NSString? {get set}
// override string to use for the track when sorting by composer
@objc optional var sortShow: NSString {get set}
@objc optional var sortShow: NSString? {get set}
// override string to use for the track when sorting by show name
@objc optional var size: CLong {get}
// the size of the track (in bytes)
@objc optional var start: CDouble {get set}
// the start time of the track in seconds
@objc optional var time: NSString {get}
@objc optional var time: NSString? {get}
// the length of the track in MM:SS format
@objc optional var trackCount: NSInteger {get set}
// the total number of tracks on the source album
Expand All @@ -627,7 +627,7 @@ extension SBObject: iTunesSubscriptionPlaylist{}
// kind of video track
@objc optional var volumeAdjustment: NSInteger {get set}
// relative volume adjustment of the track (-100% to 100%)
@objc optional var work: NSString {get set}
@objc optional var work: NSString? {get set}
// the work name of the track
@objc optional var year: NSInteger {get set}
// the year the track was recorded/released
Expand Down Expand Up @@ -661,7 +661,7 @@ extension SBObject: iTunesSharedTrack{}

// a track representing a network stream
@objc protocol iTunesURLTrack: iTunesTrack {
@objc optional var address: NSString {get set}
@objc optional var address: NSString? {get set}
// the URL for this track
}
extension SBObject: iTunesURLTrack{}
Expand Down

0 comments on commit 363b999

Please sign in to comment.