Ich bin ein Anfänger und vielleicht ist es eine triviale Frage. Ich habe diese Methode:Anruf NSString mit mehreren Parametern
-(NSString *)getInfoFormediaItem:(MPMediaItemCollection *)list {
NSString *trackCount;
if ([list count] > 0) {
trackCount = [NSString stringWithFormat:NSLocalizedString(@"%lu Songs", @""), (unsigned long)[list count]];
} else if([list count] == 1) {
trackCount = [NSString stringWithFormat:NSLocalizedString(@"1 Song", @"")];
} else {
trackCount = [NSString stringWithFormat:NSLocalizedString(@"0 Song", @"") ];
}
return [NSString stringWithFormat:@"%@", trackCount];
}
ich es nennen hier mit einem MPMediaItemCollection möchte:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
}
MPMediaQuery *playlistsQuery = [MPMediaQuery playlistsQuery];
NSArray *playl = [playlistsQuery collections];
MPMediaItem *rowItem = [playl objectAtIndex:indexPath.row];
MPMediaItemCollection * collection = [[MPMediaItemCollection alloc] initWithItems:[NSArray arrayWithObject:rowItem]];
cell.detailTextLabel.text = [self getInfoFormediaItem:collection];
}
Ich möchte die Anzahl der Spuren in jeder Wiedergabeliste erhalten. Es funktioniert nicht. Wie repariere ich? Danke im Voraus!
Die Ausführung Selektor, was Sie dort haben, ist nicht notwendig und ein wenig seltsam. Der Grund, warum es immer 0 ist, ist, dass Sie niemals ein Argument in Ihre Methode eingeben. Also [Nullzählung] ist immer 0. Sie sollten das direkt anrufen. [self getInfoForMediaItem: someMPMediaItemCollection]; – Dare