0

I am trying to retrieve the size of apple music items downloaded from the apple music library as iPod-library URL (ex. ipod-library://item/item.m4a?id=8536687568586472929) but without exporting to the document directory, I am unable to get the size.

I tried the below code.

Code:

do {
    let resources = try url.resourceValues(forKeys:[.fileSizeKey])
    let fileSize = resources.fileSize ?? 0
    print ("size \(fileSize)")
    } catch {
    print("Error: \(error)")
    }
}

Output: Couldn't fetch size for file The file “item.m4a” couldn’t be opened because there is no such file. Size: 0

0 Answers0