If you're going from NSArray
to NSMutableArray
don't just cast it, use the mutable copy.
Do i need to use mutableCopy to NSMutableArray when using MPMediaItem in iOS?
-
17-01-2022 - |
Pergunta
Hello everyone please guide me something.
I am doing custom music app with iPodMusicPlayer
.
Here is some of code i load songs from 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
.
[query items];
return NSArray
and i added to NSMutableArray
with pointer(NSMutableArray *)
Is that right way when i used like that?
or should i use like self.app.arrayFromAppDelegate = [[query items] mutableCopy];
Which way is the best for memory and do i need to use removeAllObject
after use mutableCopy
?
Please guide me.
sorry for my bad english.
Thanks you for your help.
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow