Posts

Post not yet marked as solved
1 Replies
1.2k Views
Hi, For a few days, I have more than 5000 dead tracks in my Music library. I'm a developer and I tried to fix the problem like I did before with an AppleScript library but here something strange happened. Indeed, all my dead track are on my external hard drive but the location in Music begins with "file:///Volumes/" so Music can't read the files : The correct path is the same without "file:///Volumes/" : I though it will be easy to fix that but when I try to get the tracks location to trunk it, the value is missing. So how can I fix that ? Thx
Posted Last updated
.
Post not yet marked as solved
0 Replies
529 Views
Hi, I'm trying to upgrade a project which use CocoaPods to SPM (I'm on Silicon). Problem : the project uses many dependencies including RxFirebase (https://cocoapods.org/pods/RxFirebase) which does not provide a SPM Package.swift. To isolate the problem, I tried to create a new fresh project. So I added the RxFirebase package manually but as soon as I do that and I try a build, I have the "No such module" error with many imports because I have to add the Firebase package with SPM but once it is done I have another "Count not find module" error with RxCocoa. However, it was the first dependencie I imported. As you can, it is in the RxSwift package so what's wrong ? Thx.
Posted Last updated
.
Post not yet marked as solved
3 Replies
1.2k Views
Hi, I'm working on an app based on the ITLibrary so I can get all the tracks info like their persistent ID and I'd like to play it in Music from my app. I do it easily with AppleScript so do I need to use a bridge or can I do it directly from a Swift 4 app ? Thx.
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.3k Views
Hi, I'm working on a project that uses GIT on my Synology NAS. I cloned the repo in command line in the terminal and after that I created my Xcode project in the folder cloned. When I try to commit / push my files, I have the "username does not match previous request (-1)" error : I think it is because Xcode doesn't know the account to connect to my Synology GIT server. If I type the push command in the terminal "git push -u origin master", it asks me my password and it is pushed but Xcode asks nothing and the error occurs. How to add my account ? Thx.
Posted Last updated
.
Post marked as solved
8 Replies
1.2k Views
Hi, I use a predicate to filter a NSTableView when I type in a NSSearchField : private func _filterTracks(str: String) {         var thePredicates = [NSPredicate]()         let theArtistPredicate = NSPredicate(format: FilterType.format, FilterType.artistField, str)         let theTitlePredicate = NSPredicate(format: FilterType.format, FilterType.titleField, str)         let theAlbumPredicate = NSPredicate(format: FilterType.format, FilterType.albumField, str)                  switch _filter?.tag {         case FilterType.FilterListType.ALL.rawValue:             thePredicates.append(theArtistPredicate)             thePredicates.append(theTitlePredicate)             thePredicates.append(theAlbumPredicate)         case FilterType.FilterListType.artist.rawValue:             thePredicates.append(theArtistPredicate)         case FilterType.FilterListType.album.rawValue:             thePredicates.append(theAlbumPredicate)         case FilterType.FilterListType.title.rawValue:             thePredicates.append(theTitlePredicate)         default:             thePredicates.append(theArtistPredicate)             thePredicates.append(theTitlePredicate)             thePredicates.append(theAlbumPredicate)         }         let theCompoundPredicate = NSCompoundPredicate(type: NSCompoundPredicate.LogicalType.or, subpredicates: thePredicates)         arrayController.filterPredicate = theCompoundPredicate     } But when the NSSearchField is reset, how to reset the filter and get the datas in the NSTableView like it was ? Thx.
Posted Last updated
.
Post not yet marked as solved
10 Replies
1.5k Views
Hi,I'm looking for a way to get all the iTunes artists and their albums in a tree (like the playlists in iTunes which I get like it).I tried an algo where I get all the media items filtered by mediaKind == .kindSong sorted by artist and after that, I "while" loop in all the media items count (about 36 000 for me (iTunes user for 15 years 😝)) to filter them by artist name and after that by album title so each time, I increase the i + the count of the results to go to the next artist and then next album for each artist.It is working but it is very slow. I think it is because of the array filter function of the media items list which loop into all the array (right ?) to find the criteria. But as I sorted it just before to start the loop, it could be faster to stop it as soon as the artist name is not the same than the previous (or something like that...).Here is the 2 main func I use :static func getArtistsTree(theITTracks: [ITLibMediaItem], theLenght: Int) -> [Artist] { var theArtists: [Artist] = [Artist]() // just a custon obj to record the artists let theArtistNames = getAllArtistNames(theITTracks: theITTracks).sorted() for theArtistName in theArtistNames { let theArtistResults = theITTracks.filter({$0.artist?.name?.lowercased() == theArtistName.lowercased()}).sorted(by: {self.sortITTrack(ITTrack1: $0, ITTrack2: $1, kind: ITSortKind.album)}) print("V&G_Project___theArtistResult.count : ", theArtistResults.count) var i: Int = 0 while i < theArtistResults.count { let theArtistTrack = theArtistResults[i] if let theAlbumTitle = theArtistTrack.album.title { let theAlbumResults = theArtistResults.filter({$0.album.title?.lowercased() == theAlbumTitle.lowercased()}) print("V&G_Project___name : ", theArtistTrack.artist?.name, " - ", theAlbumTitle, "theAlbumResults.count : " + String(theAlbumResults.count)) var j: Int = 0 while j < theAlbumResults.count { let theAlbum = theAlbumResults[j] let theTracksResults = theAlbumResults.filter({$0.album.title?.lowercased() == theAlbumTitle.lowercased()}) j += 1 } i += theAlbumResults.count } else { i += 1 } } print("V&G_Project___--------------- : ") } return theArtists } static func getAllArtistNames(theITTracks: [ITLibMediaItem]) -> [String] { var theArtistsList: [String] = [String]() for theITTrack in theITTracks { let theArtistName = theITTrack.artist?.name var theToto: String = "unknown" if let theArtistName = theArtistName { theToto = theArtistName } let theIndex = theArtistsList.index(of: theToto) print("V&G_Project___getAllArtistNames : ", theIndex) if theIndex == nil { theArtistsList.append(theToto) } } return theArtistsList } do { let lib = try ITLibrary(apiVersion: "1.0") let theITTracks = lib.allMediaItems.filter({$0.mediaKind == .kindSong}) let theArtistsTree = iTunesModel.getArtistsTree(theITTracks: theITTracks, theLenght: theITTracks.count) } catch let error { print("V&G_Project___<#name#> : ", error) }I can use only one func to save one loop but even with one, everything works fine but the algorythm is very slooooww and I need to improve it.Any idea ?Thx.
Posted Last updated
.
Post not yet marked as solved
0 Replies
446 Views
Hi, Following my artists / albums / tracks tree, I decided to redo my playlists tree which was working but was a quite slow and complicated. So I have that recursive func now : let lib = try ITLibrary(apiVersion: "1.1") let theITPlaylists = lib.allPlaylists let theRootITPlaylists = theITPlaylists.filter({ $0.parentID == nil }) let thePlaylistsTree = getPlaylistsTree(theLevelITPlaylists: theRootITPlaylists, theITPlaylists: theITPlaylists) func getPlaylistsTree(theLevelITPlaylists: [ITLibPlaylist], theITPlaylists: [ITLibPlaylist]) -> [Playlist] { var thePlaylistsTree = [Playlist]() for theITPlaylist in theLevelITPlaylists { let thePlaylist = Playlist(thePlaylist: theITPlaylist) // a NSObject with the isLeaf bool and children array to show the tree in a NSOutlineView if theITPlaylist.kind == .folder { let theChildrenPlaylists = theITPlaylists.filter({ $0.parentID == theITPlaylist.persistentID }) thePlaylist.children = getPlaylistsTree(theLevelITPlaylists: theChildrenPlaylists, theITPlaylists: theITPlaylists) } thePlaylistsTree.append(thePlaylist) } return thePlaylistsTree } Very simple. But I think I can improve it more by deleting the playlists in the theITPlaylists array once it is added in the tree. Like that, the filter to search for the children's playlist folder could be more efficient : let theChildrenITPlaylists = theITPlaylists.filter({ $0.parentID == theFolderITPlaylist.persistentID }) Instead of filtering all the playlists, I just filter the remaining playlists, right ? But is it faster or whatever the array.count is, it still the same ? How can I do that ? Thx.
Posted Last updated
.
Post not yet marked as solved
1 Replies
798 Views
Hi, I have a NSOutlineView populated by a NSTreeController and I'd like to filter it with a NSSearchField : According to this post, it is not possible directly because NSTreeController doesn't have a filter predicate but according to that answer, we could filter the nodes of the array which is the content of the NSTreeController. I tried this method but I don't have the good result : Some nodes which does not contain the string still stay in the NSOutlineView. Like I said in this post, I'm not familiar with the predicates so maybe my error comes from that. Here it is : let thePredicate = NSPredicate(format: "%K CONTAINS[cd] %@", "name", theStr) Also, the difficulty here is I need to keep the parent node even if it doesn't have the predicate condition if one of its child has it. Other second solution is to put the result in a NSTableView but I need to build the same cell than in the NSOutlineView, etc... Any idea ? Thx.
Posted Last updated
.
Post not yet marked as solved
5 Replies
1.3k Views
Hello,I'd like to add a dropdown to a NSSearchField with different filters, like the search field in iTunes.I'm new to Cocoa but I was a Flash / Flex develop which has many similarities with the subclassing and I'm looking for the methods to subclass, or is it better to compose with the NSSearchField in a XIB ?I tried to subclass the draw method with a super call but as soon as I do that, the NSSearchField lose its focus animation.Thx a lot.
Posted Last updated
.
Post not yet marked as solved
2 Replies
973 Views
Hi, Is it possible ? How ? I have a NSTableView binded to a NSArrayController programatically and I’d like to filter it with a NSSearchField with criteria or not. Thx.
Posted Last updated
.
Post marked as solved
10 Replies
1k Views
Hi, Like in the Music App, I load my playlists and show them in a tree and then when I click a playlist, a TableView shows its content. After that I select some tracks to add it to another TableView at the bottom : I add the data programmatically but maybe it could be better to use the binding because actually I have a problem to remove the selected items at the bottom. Indeed I have to maintain the datas manually when an item is removed and it costs a lot of work... Any idea about that ? Thx.
Posted Last updated
.
Post not yet marked as solved
0 Replies
539 Views
Hi, A few mouth ago, I was working on a project that uses the ITLibrary API and the ITLibPlaylist class to load the music playlists in a tree and get the tracks when a playlist is selected. Now I'd like to work again on this project but as soon as I try to load the playlists, I have a memory bug. But I also try to load my playlists and its tracks in a fresh new project and it is working so something in my view has a bug : Maybe a problem with the links between the UI and the data... Any idea ? Thx.
Posted Last updated
.