문제

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.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top