Skip to content

Commit

Permalink
conversion to swift 5 (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
anubhavpulkit authored Jul 2, 2020
1 parent c8d85e4 commit f8c52a0
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions AmahiAnywhere/AmahiAnywhere.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@
TargetAttributes = {
FB71BE93201CB2FC0005492C = {
CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 1000;
LastSwiftMigration = 1140;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.AccessWiFi = {
Expand Down Expand Up @@ -1103,7 +1103,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ENFORCE_EXCLUSIVE_ACCESS = none;
SWIFT_OBJC_BRIDGING_HEADER = "AmahiAnywhere/AmahiAnywhere-Bridging-Header.h";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -1128,7 +1128,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ENFORCE_EXCLUSIVE_ACCESS = none;
SWIFT_OBJC_BRIDGING_HEADER = "AmahiAnywhere/AmahiAnywhere-Bridging-Header.h";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class BaseUITableViewController: UITableViewController, GCKSessionManagerListene
return
}
if !visible {
let index = barItems?.index(of: queueButton)
let index = barItems?.firstIndex(of: queueButton)
if index == 1 {
barItems?.remove(at: 1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class BaseUIViewController: UIViewController, GCKSessionManagerListener, GCKRequ
barItems?.append(queueButton)
navigationItem.rightBarButtonItems = barItems
} else{
if let index = barItems?.index(of: queueButton){
if let index = barItems?.firstIndex(of: queueButton){
navigationItem.rightBarButtonItems?.remove(at: index)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extension AudioPlayerViewController{
player.replaceCurrentItem(with: playerItems[shuffledArray[0]])
shuffledArray.removeFirst()
}else{
var index = playerItems.index(of: player.currentItem!) ?? 0
var index = playerItems.firstIndex(of: player.currentItem!) ?? 0
if index == playerItems.count - 1 {
index = 0
}else {
Expand All @@ -72,7 +72,7 @@ extension AudioPlayerViewController{

if timeElapsedLabel.text == "00:00" || timeElapsedLabel.text == "00:01" || timeElapsedLabel.text == "00:02"{
// Previous song
var index = playerItems.index(of: player.currentItem!) ?? 0
var index = playerItems.firstIndex(of: player.currentItem!) ?? 0

if index == 0 {
index = playerItems.count - 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MediaPlayer
extension AudioPlayerViewController{

func setImage(){
let url = itemURLs[playerItems.index(of: player.currentItem!) ?? 0]
let url = itemURLs[playerItems.firstIndex(of: player.currentItem!) ?? 0]
if let image = AudioThumbnailGenerator.imageFromMemory(for: url){
loadImage(image: image)
}else{
Expand All @@ -34,7 +34,7 @@ extension AudioPlayerViewController{
track = trackName
artist = artistName
}else{
let asset:AVAsset = AVAsset(url:itemURLs[playerItems.index(of: player.currentItem!) ?? 0])
let asset:AVAsset = AVAsset(url:itemURLs[playerItems.firstIndex(of: player.currentItem!) ?? 0])
let metaData = asset.metadata

let artistNameMetaData = AVMetadataItem.metadataItems(from: metaData, filteredByIdentifier: AVMetadataIdentifier.commonIdentifierArtist)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class AudioPlayerViewController: UIViewController {
}

@IBAction func nextButtonPressed(_ sender: Any) {
let index = playerItems.index(of: player.currentItem!) ?? 0
let index = playerItems.firstIndex(of: player.currentItem!) ?? 0
if index == playerItems.count - 1 && repeatButton.currentImage != UIImage(named:"repeatCurrent"){
repeatButton.setImage(UIImage(named:"repeatAll"), for: .normal)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Audio2PlayerViewController: UIViewController {
}

@IBAction func nextButtonPressed(_ sender: Any) {
let index = playerItems.index(of: player.currentItem!) ?? 0
let index = playerItems.firstIndex(of: player.currentItem!) ?? 0
if index == playerItems.count - 1 {
repeatButton.setImage(UIImage(named:"repeatAll"), for: .normal)
}
Expand Down Expand Up @@ -118,7 +118,7 @@ class Audio2PlayerViewController: UIViewController {
shuffledArray.removeFirst()
}
else{
var index = playerItems.index(of: player.currentItem!) ?? 0
var index = playerItems.firstIndex(of: player.currentItem!) ?? 0
if index == playerItems.count - 1 {
player.pause()
configurePlayButton()
Expand Down Expand Up @@ -152,7 +152,7 @@ class Audio2PlayerViewController: UIViewController {
shuffledArray.removeFirst()
}
else{
var index = playerItems.index(of: player.currentItem!) ?? 0
var index = playerItems.firstIndex(of: player.currentItem!) ?? 0
if index == playerItems.count - 1 {
index = 0
}
Expand All @@ -163,7 +163,7 @@ class Audio2PlayerViewController: UIViewController {
}
}
if repeatButton.currentImage == UIImage(named:"repeatCurrent") {
let index = playerItems.index(of: player.currentItem!) ?? 0
let index = playerItems.firstIndex(of: player.currentItem!) ?? 0
self.player?.seek(to: CMTime.zero)
player.replaceCurrentItem(with: playerItems[index])
}
Expand All @@ -177,7 +177,7 @@ class Audio2PlayerViewController: UIViewController {
player.rate = 0
configurePlayButton()
player.seek(to: CMTime.zero)
var index = playerItems.index(of: player.currentItem!) ?? 0
var index = playerItems.firstIndex(of: player.currentItem!) ?? 0
if index == 0 {
index = playerItems.count - 1
}
Expand All @@ -204,7 +204,7 @@ class Audio2PlayerViewController: UIViewController {
var track: String = ""
var artist: String = ""

let asset:AVAsset = AVAsset(url:itemURLs[playerItems.index(of: player.currentItem!) ?? 0])
let asset:AVAsset = AVAsset(url:itemURLs[playerItems.firstIndex(of: player.currentItem!) ?? 0])
for metaDataItems in asset.commonMetadata {
//getting the title of the song
//getting the thumbnail image associated with file
Expand All @@ -221,15 +221,15 @@ class Audio2PlayerViewController: UIViewController {
}

func setArtWork(){
let url = self.itemURLs[self.playerItems.index(of: self.player.currentItem!) ?? 0]
let url = self.itemURLs[self.playerItems.firstIndex(of: self.player.currentItem!) ?? 0]

if let image = AudioThumbnailGenerator.imageFromMemory(for: url){
self.musicArtImageView.image = image
self.backgroundImageView.image = image
self.setLockScreenMetadata()
}else{
DispatchQueue.global(qos: .userInitiated).async {
let image = AudioThumbnailGenerator().getThumbnail(self.itemURLs[self.playerItems.index(of: self.player.currentItem!) ?? 0])
let image = AudioThumbnailGenerator().getThumbnail(self.itemURLs[self.playerItems.firstIndex(of: self.player.currentItem!) ?? 0])
DispatchQueue.main.async {
self.musicArtImageView.image = image
self.backgroundImageView.image = image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ extension OfflineFilesViewController: NSFetchedResultsControllerDelegate {
cell.updateProgress(offlineFile: file)
}
}
}else if type == .delete, let file = anObject as? OfflineFile, let deletedIndex = offlineFiles.index(of: file){
}else if type == .delete, let file = anObject as? OfflineFile, let deletedIndex = offlineFiles.firstIndex(of: file){
offlineFiles.remove(at: deletedIndex)
organiseFilesSections(offlineFiles)
NotificationCenter.default.post(name: .OfflineFileDeleted, object: file, userInfo: ["loadOfflineFiles": true])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ConnectionViewController: BaseUITableViewController {
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let index = connectionItem.index(of: LocalStorage.shared.userConnectionPreference) {
if let index = connectionItem.firstIndex(of: LocalStorage.shared.userConnectionPreference) {
let cell = tableView.cellForRow(at: IndexPath(row: index, section: 0))
cell?.accessoryType = .none
}
Expand Down

0 comments on commit f8c52a0

Please sign in to comment.