以编程方式访问iTunes资料库时出现问题

编程入门 行业动态 更新时间:2024-10-18 03:23:00
本文介绍了以编程方式访问iTunes资料库时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我构建了一个必须访问iTunes资料库的应用程序.我使用MPMediaQuer从库中检索歌曲,如下所示.

I built an app that must access the iTunes library. I used MPMediaQuer to retrieve songs from the library as in the following.

MPMediaQuery *media = [[MPMediaQuery alloc]init]; NSArray *arr = [media items]; for(MPMediaItem *song in arr) { //To print songs title NSString *title = [song valueForProperty:MPMediaItemPropertyTitle]; NSLog(@"%@", title); }

但是什么也没印出来!

然后我尝试打印arr数组的计数,结果为0,如下所示.

And I tried to print the count of the arr array and the result is 0 as in the following.

NSLog(@"%D",[arr count]);

我确定iTunes库中有一些歌曲.

And I'm sure there are some songs in the iTunes Library.

因为我在模拟器中进行测试,会发生此问题吗?而且,如果我在设备上测试代码是否可以正常工作?

Do this problem occur because I test in the simulator? And if I test the code on device should it work?

推荐答案

iPod库访问API 仅适用于设备,这就是为什么在iPhone Simulator上没有得到任何结果的原因:

The iPod Library Access APIs only works on devices, that's why you aren't getting any result on the iPhone Simulator:

注意:仅可访问iPod库 在设备上而不在模拟器中. 这是因为模拟器没有 访问设备的iPod库.到 使用类开发应用程序 在这项技术中,您需要 预配的iOS设备.

Note: iPod library access works only on devices and not in the Simulator. This is because the Simulator has no access to a device’s iPod library. To develop applications using the classes in this technology, you need a provisioned iOS device.

更多推荐

以编程方式访问iTunes资料库时出现问题

本文发布于:2023-11-23 20:37:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622792.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:资料库   方式   iTunes

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!