You've already accessed the answers array, now simply access the item within the array:
MPMediaItem *item = [self.question[0] answers][0];
Вопрос
I have two classes:
MusicQuestion
which has this property:
@property (nonatomic, strong) NSArray *answers; // array of MPMediaItem
MusicQuiz
which has this property:
@property (nonatomic, strong) NSMutableArray *questions; // array of MusicQuestion
I want to access, from MusicQuiz
, answers[0]
inside question[0]
. I tried this:
[self.question[0] answers] // It only access the entire array of the first question
How can I do it?
Решение
You've already accessed the answers array, now simply access the item within the array:
MPMediaItem *item = [self.question[0] answers][0];
Другие советы
MPMediaItem *item = [[self.question[0] answers] objectAtIndex:0];
NSArray *answers = [self.questions[0] answers]; //This is the answers array of the first question
MPMediaItem *item = answers[0]; //This is that MPMediaItem you want.