2013-01-16 29 views
0

我收到此錯誤信息: - [MPConcreteMediaItem isEqualToString:]:無法識別的選擇發送到實例...Xcode的故事板Segue公司以歌名傳遞從陣列詳細視圖控制器

我創造的,從媒體選擇歌曲的NSMutable數組命名的數組「陣列」。該數組在tableview(myTable)中正確顯示。但是,當我嘗試繼續播放詳細信息視圖並將歌曲標題發送到本教程後面的詳細信息視圖上的標籤時。我收到上面的崩潰和錯誤消息。

感謝任何幫助,謝謝!

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 

    if ([[segue identifier] isEqualToString:@"detailView"]) { 

    NSIndexPath *indexPath = [self.myTable indexPathForSelectedRow]; 

    DetailViewController *vc = [segue destinationViewController]; 

    vc.trackName = [array objectAtIndex:indexPath.row]; 

    //crashes -[MPConcreteMediaItem isEqualToString:]: unrecognized selector sent to instance 

    } 

} 

- (void)mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection { 

    [array addObjectsFromArray:mediaItemCollection.items]; 

    [myTable reloadData]; 

    // mediaItemCollection = nil; 

    [mediaPicker dismissViewControllerAnimated:YES completion:nil]; 

} 

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    //this method is called to fill out table with data 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; 

    if (cell == nil) { 

    cell = [[UITableViewCell alloc] 

    initWithStyle:UITableViewCellStyleDefault 

    reuseIdentifier:@"Cell"]; 

} 

    // Configure the cell 

    anItem = nil; 

    anItem = [array objectAtIndex:indexPath.row]; 

    cell.textLabel.text = [anItem valueForProperty:MPMediaItemPropertyTitle]; 

    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 

    return cell; 

} 

回答

0

錯誤看起來,你是不是叫「isEqualToString:」字符串對象...這超有MPConcreteMediaItem

+0

應該在哪裏我可以呼籲「isEqualToString:」?在trackName =數組objectatindex?對不起,我不明白。謝謝! – user1304216

+0

我試過這個,但可能不是你的意思:vc.trackName = [NSString stringWithFormat:@「%@」,[array objectAtIndex:indexPath.row]]; - 代替我得到的歌曲名稱,MPConcreteMediaItem 0x1fd09830>後跟一串數字。當然,我試圖從表格視圖選定行中的數組中獲取歌曲標題到詳細視圖中的標籤上。謝謝! – user1304216

+0

這解決了這個問題:NSIndexPath * indexPath = [self.myTable indexPathForSelectedRow]; //引用目標視圖控制器 DetailViewController * vc = [segue destinationViewController]; MPMediaItem * songToPlay = [數組objectAtIndex:indexPath.row]; NSString * titleString = [songToPlay valueForProperty:MPMediaItemPropertyTitle]; vc.trackName = titleString; – user1304216

相關問題