数组未显示在表视图中



谁能告诉我为什么我的代码在我的表视图中没有显示任何结果。这是我的代码。我已经尝试将@"@"更改为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;
}

很难说你在方法中做什么,waitAndFillPlaylistPool,但如果这需要任何时间来获取这些数据,那么你需要在你的表视图([self.tableView reloadData](上调用reloadData作为该方法的最后一行(或者当任何异步方法返回时 - 我无法判断它可能在你的代码中的位置(。

相关内容

  • 没有找到相关文章

最新更新