I am a beginner with Swift programming who is trying to re-write code that I found online that Finds A Song from Persistent ID. The original code is found at this website:
I want to write this code in Swift 2 (I won't use Objective-C), but I lack the knowledge and experience to translate it.
The code:
MPMediaItem *song;
MPMediaPropertyPredicate *predicate;
MPMediaQuery *songQuery;
predicate = [MPMediaPropertyPredicate predicateWithValue: MyPersistentIdString forProperty:MPMediaItemPropertyPersistentID];
songQuery = [[MPMediaQuery alloc] init];
[songQuery addFilterPredicate: predicate];
if (songQuery.items.count > 0)
{
//song exists
song = [songQuery.items objectAtIndex:0];
CellDetailLabel = [CellDetailLabel stringByAppendingString:[song valueForProperty: MPMediaItemPropertyTitle]];
}
My questions:
1) Is this code re-writeable to Swift, is it still current enough without depreciations?
2) How would I go about calling this code using a function?