Open Nytrm opened 6 months ago
Could you try return self.library.applicationVersion
? iirc String
conforms to NodeValueConvertible
. Let me know if that works.
Regarding docs, definitely agree that there's a lot of room for improvement. I'd ideally like to create a DocC catalog but haven't got around to it yet due to a lack of time. It's on the roadmap though.
The string can be returned from your class simply like this.
@NodeProperty var version: String { return library.applicationVersion }
I couldn't get the playlists to work from a NodeClass
, but you can wrap each ITLibPlaylist
item directly from the NodeFunction
import NodeAPI
import iTunesLibrary
@NodeClass final class NodePlaylist {
var playlist: ITLibPlaylist
init(playlist: ITLibPlaylist) { self.playlist = playlist }
// simple types
@NodeProperty var name: String { playlist.name }
// some type mapping might be necessary (NSNumber? -> Double?)
@NodeProperty var parendID: Double? { playlist.parentID == nil ? nil : Double(exactly: playlist.parentID!) }
// ... map other properties
}
#NodeModule(exports: [
"allPlaylists": try NodeFunction { () in
let library = try ITLibrary(apiVersion: "1.0")
return library.allPlaylists.map { NodePlaylist(playlist: $0) }
}
])
Hi, great project but the example seems just a little minimal.
I am trying to access the iTunesLibrary from node but i am not sure how to map the values/types to return types. In this example its just a string that does not seem to work for me.
no exact matches in call to initializer return NodeValue(self.library.applicationVersion)
my plan was to map playlist but i got stuck with just the string. https://developer.apple.com/documentation/ituneslibrary/itlibrary/allplaylists