1

コードがテーブル ビューに結果を表示しない理由を誰か教えてください。これが私のコードです。@"@" を indexPath.row に変更しようとしましたが、うまくいきませんでした。私は正しい方向への答えを探しています。私はxcodeとobjective-cにかなり慣れていません。助けていただければ幸いです。

-(void)waitAndFillPlaylistPool {
    // arrPlaylist -> mutablearray which stores the value of loaded playlist in order to use it later


    [SPAsyncLoading waitUntilLoaded:[SPSession sharedSession] timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedession, NSArray *notLoadedSession)
     {
         // The session is logged in and loaded — now wait for the userPlaylists to load.
         NSLog(@"[%@ %@]: %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), @"Session loaded.");

         [SPAsyncLoading waitUntilLoaded:[SPSession sharedSession].userPlaylists timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedContainers, NSArray *notLoadedContainers)
          {
              // User playlists are loaded — wait for playlists to load their metadata.
              NSLog(@"[%@ %@]: %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), @"Container loaded.");

              NSMutableArray *playlists = [NSMutableArray array];
              [playlists addObject:[SPSession sharedSession].starredPlaylist];
              [playlists addObject:[SPSession sharedSession].inboxPlaylist];
              [playlists addObjectsFromArray:[SPSession sharedSession].userPlaylists.flattenedPlaylists];

              [SPAsyncLoading waitUntilLoaded:playlists timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedPlaylists, NSArray *notLoadedPlaylists)
               {
                   // All of our playlists have loaded their metadata — wait for all tracks to load their metadata.
                   NSLog(@"[%@ %@]: %@ of %@ playlists loaded.", NSStringFromClass([self class]), NSStringFromSelector(_cmd),
                         [NSNumber numberWithInteger:loadedPlaylists.count], [NSNumber numberWithInteger:loadedPlaylists.count + notLoadedPlaylists.count]);
                   NSLog(@"loadedPlaylists >> %@",loadedPlaylists);

                   arrPlaylist = [[NSMutableArray alloc] initWithArray:loadedPlaylists];
                   NSLog(@"arrPlaylist >> %@",arrPlaylist);

               }];
          }];
     }];
}


- (NSInteger) tableView:(UITableView *) tableView numberOfRowsInSection:(NSInteger)section {

    return [arrPlaylist count];
}

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

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

        cell.textLabel.text = [arrPlaylist objectAtIndex:indexPath.row];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;


    return cell;
}
4

1 に答える 1

0

メソッド waitAndFillPlaylistPool で何をしているのかわかりにくいですが、このデータを取得するのに時間がかかる場合は、テーブル ビュー ([self.tableView reloadData]) で reloadData を最後の行として呼び出す必要があります。そのメソッド (または非同期メソッドが返されたとき - コード内のどこにあるのかわかりません)。

于 2013-07-08T04:14:38.127 に答える