简体   繁体   English

在iOS中使用MPMediaItem时需要使用mutableCopy到NSMutableArray吗?

[英]Do i need to use mutableCopy to NSMutableArray when using MPMediaItem in iOS?

Hello everyone please guide me something. 大家好,请指导我。

I am doing custom music app with iPodMusicPlayer . 我正在使用iPodMusicPlayer做自定义音乐应用程序。

Here is some of code i load songs from iPodLibrary. 这是一些我从iPodLibrary加载歌曲的代码。

MPMediaQuery *query = [MPMediaQuery playlistsQuery];

        MPMediaPropertyPredicate *filter = [MPMediaPropertyPredicate predicateWithValue:self.playlistName forProperty:MPMediaPlaylistPropertyName comparisonType:MPMediaPredicateComparisonContains];

        [query addFilterPredicate:filter];      

**self.app.arrayFromAppDelegate = (NSMutableArray *)[query items];**


        self.userMediaItemCollection = [[MPMediaItemCollection alloc] initWithItems:self.app.arrayFromAppDelegate];

        [self.player setQueueWithItemCollection:self.userMediaItemCollection];

according to above code 根据上面的代码

self.app.arrayFromAppDelegate = (NSMutableArray *)[query items];

arrayFromAppDelegate is a NSMutableArray that i declared in AppDelegate . arrayFromAppDelegate是我在AppDelegate声明的NSMutableArray [query items]; return NSArray and i added to NSMutableArray with pointer (NSMutableArray *) 返回NSArray ,我使用指针将其添加到NSMutableArray (NSMutableArray *)

Is that right way when i used like that? 当我那样使用时是正确的方式吗?

or should i use like self.app.arrayFromAppDelegate = [[query items] mutableCopy]; 还是我应该使用如self.app.arrayFromAppDelegate = [[query items] mutableCopy];

Which way is the best for memory and do i need to use removeAllObject after use mutableCopy ? 哪种方式最适合内存,在使用mutableCopy之后是否需要使用removeAllObject

Please guide me. 请指导我。

sorry for my bad english. 对不起,我的英语不好。

Thanks you for your help. 感谢您的帮助。

如果您要从NSArrayNSMutableArray请不要使用强制复制,而是使用可变副本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift iOS,何时需要使用mediaTypes kUTTypeImage - swift ios when do I need to use mediaTypes kUTTypeImage NSMutableArray与init和mutableCopy,如何自动释放? - NSMutableArray with init and mutableCopy, how to autorelease? iOS ARC NSMutableArray我是否需要在为其分配新内存之前先删除AllObjects - IOS ARC NSMutableArray do I need to removeAllObjects before alloc new memory for it iOS我应该使用NSMutableArray还是NSM​​utableDictionary? - iOS should I use NSMutableArray or NSMutableDictionary? 我什么时候需要在iOS中调用setNeedsDisplay? - When do I need to call setNeedsDisplay in iOS? 当我在iOS中使用FB SDK时,我是否需要从Facebook成功审核? - Do i need to success review from Facebook when i use FB SDK in iOS? iOS:如何使用NSMutableArray - IOS: how to use NSMutableArray 为什么仅当我使用mutableCopy时,此NSMutableAttributedString addAttribute才起作用 - Why does this NSMutableAttributedString addAttribute work only if I use a mutableCopy Swift 3:可变拷贝的模棱两可使用 - Swift 3 : Ambiguous use of mutablecopy 在iOS上使用tgmath我需要做什么? - What do I need to do to use tgmath on iOS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM