Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8562635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:46:19+00:00 2026-06-11T16:46:19+00:00

If I try to add an opened UIDocument into an array I get nothing

  • 0

If I try to add an opened UIDocument into an array I get nothing out. This might be how it is supposed to work, I’m not sure.

- (void)loadDocAtURL:(NSURL *)fileURL withClassName:(NSString *)className {


    id doc = [[NSClassFromString(className) alloc] initWithFileURL:fileURL];

    [doc openWithCompletionHandler:^(BOOL success) {


        if (!success) {
            NSLog(@"Failed to open %@", fileURL);
            return;
        }

        NSLog(@"I'm a doc. My class is %@, my title is %@", NSStringFromClass([doc class]), [doc title]);

        dispatch_async(dispatch_get_main_queue(), ^{
        //[self addOrUpdateEntryWithURL:fileURL metadata:metadata state:state version:version];
        [_tableList addObject:doc];
        [self.tableView reloadData];
        NSLog(@"%d", _tableList.count);
        });

    }];

};

That NSLog returns: I’m a doc. My class is Song, my title is A New Song

So far so good.

[self.tableView reloadData], reloads the table correctly and the correct number of cells are displayed, only they are empty, this is why:

- (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];
    }

    Song *theSong = [tableList objectAtIndex:indexPath.row];
    NSLog(@"I am a %@", NSStringFromClass([theSong class]));
    UILabel *titleLabel = (UILabel *)[cell viewWithTag:0];
    UILabel *lyricLabel = (UILabel *)[cell viewWithTag:1];
    NSLog(@"I'm in the table view. My title is %@", [theSong lyric]);
    titleLabel.text = theSong.title;
    lyricLabel.text = theSong.lyric;
    [theSong closeWithCompletionHandler:^(BOOL success) {

        // Check status
        if (!success) {
            NSLog(@"Failed to close %@", theSong.fileURL);
            // Continue anyway...
        }

        }];
    return cell;
}

Those two NSLogs output: I am a (null) and I’m in the table view. My title is (null)

When I breakpoint and look at theSong after its grabbed, it is completely empty.

This is leading me to think that you cannot open a UIDocument, stick it in an array and pull it back out of the array. Am I correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:46:20+00:00Added an answer on June 11, 2026 at 4:46 pm

    If the song is nil, then almost certainly the array is nil. I notice you refer to it both as _tableList and as tableList. My guess is those are not the same pointer.

    Try using _tableList in cellForRowAtIndexPath. Log it to confirm that it’s non-nil.

    You can disprove your theory about the array by logging [_tableList lastObject] right after you add it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to add struct in two-dimensional array cin>>array[1][items.stoka_ime]; in error list write
Getting this error when try to add an item to my repositories/context: Collection has
Here is the source -- I get errors when I try to add +
i try to add facebook like button on my root domain that will like
I try to add the android coverflow in my own android projet when myt
I try to add dots between the page title and the page number in
I try to add Message.framework to my project frameworks directory. After that I compile
I try to add a class to a td-element using javascript with the internet
I try to add a class to a link with jquery <a rel=/Career/ href=/Career/></a>
If I try to add a tab to the toolbox and name it 'Clipboard

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.