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

  • SEARCH
  • Home
  • 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 6662665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:24:51+00:00 2026-05-26T02:24:51+00:00

I have a read-only text field that I use as a log display. I

  • 0

I have a read-only text field that I use as a log display. I have a operation that removes all the files in app’s document directory. I want to insert a line of log when I remove each file. But the text field is only updated when the whole operation got finished. How do I fix this?

Here is my code:

NSFileManager *fm = [[[NSFileManager alloc] init] autorelease];
NSError *error = nil;
for (NSString *fileName in array) {
    NSString *filePath = [DOCUMENT_PATH_VALUE stringByAppendingFormat:@"/%@", fileName];
    [fm removeItemAtPath:filePath error:&error];

    if (!error) {
        NSString *log = [NSString stringWithFormat:@"removed success: %@", fileName];
        [self logThis:log];
    }else{
        NSString *log = [NSString stringWithFormat:@"remove failed: %@, %@", fileName, [error localizedDescription] ];
        [self logThis:log];

-(void)logThis:(NSString*) text{
    NSRange range = NSMakeRange([updateLogTextView.text length], [text length]);
    updateLogTextView.text = [updateLogTextView.text stringByAppendingFormat:@"%@\n", text]; 

    [updateLogTextView scrollRangeToVisible:range];
}
  • 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-05-26T02:24:51+00:00Added an answer on May 26, 2026 at 2:24 am

    You need to move your long-running operation into a background thread/queue and make sure that your UI-updating code is always executed on the main thread.

    Example:

    - (void)processFiles:(NSArray *)array
    {
        //You need to create your own autorelease pool in background threads:
        NSAutoreleasePool *pool = [NSAutoreleasePool new];
        //...
        NSString *log = ...;
        [self performSelectorOnMainThread:@selector(logThis:) withObject:log waitUntilDone:NO];
        //...
        [pool release];
    }
    

    You would then start your operation using:

    [self performSelectorInBackground:@selector(processFiles:) withObject:files];
    

    Using Grand Central Dispatch with blocks would be another option.

    Refer to the Threading Programming Guide and the Concurrency Programming Guide for more in-depth information.

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

Sidebar

Related Questions

I have a web page with a read-only text box which shows some HTML
Now that I have a read-only application working, I am working on the insert
I have a class that defines a read-only property that effectively exposes a private
I have a set of files. The set of files is read-only off a
Our site's UI displays read-only text fields which have mouse-click handlers -- when the
I have been trying to update a text field in a form that will
Is there a way to have a UITextField with the text read only but
Many library classes in AS3 have read only properties. Is it possible to create
I have a read only combo-box with 5 values in, when the user selects
Possible Duplicate: Can Read-Only Properties be Implemented in Pure JavaScript? I have an Object

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.