in Education by
i'm trying to get directory file listing from my ftp server using Chilkat library. In this case, i want to animating a UIActivityIndicatorView when the process is running. But the problem is, the UIActivityIndicatorView never start to animate. The code I use is : [self.activityIndicator startAnimating]; [selfgetListFromPath:ftpPath withConnection:ftpConnect]; [self.activityIndicator stopAnimating]; activityIndicator is an object of UIActivityIndicatorView, ftpPath is a NSString of my file path in FTP server, and getListFromPath is the method for getting list from FTP server using Chilkat algorithm, ftpConnect is an object of FTP Connection Class. I was try to use NSRunLoop before called getListFromPath function, so I changed my code into : [self.activityIndicator startAnimating]; BOOL waitingOnProcessing = YES; NSRunLoop *currentRunLoop = [NSRunLoop currentRunLoop]; while (waitingOnProcessing && [currentRunLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]) { } [self getListFromPath:ftpPath withConnection:ftpConnect]; [self.activityIndicator stopAnimating]; this make the activityIndicator animating, but the getListFromPath never fired. After a trial, i choosed to changed again my code into : [self.activityIndicator startAnimating]; BOOL waitingOnProcessing = YES; NSRunLoop *currentRunLoop = [NSRunLoop currentRunLoop]; while (waitingOnProcessing && [currentRunLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]) { waitingOnProcessing = NO; } [self getListFromPath:ftpPath withConnection:ftpConnect]; [self.activityIndicator stopAnimating]; it make the activityIndicator animating, and also fired the getListFromPath function. But i'm doubt with this code, am i right with this code? or maybe there is a bad practice for using NSRunLoop? can somebody tell me Thank you JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
This code runs as in a "black box" : [self.activityIndicator startAnimating]; [self getListFromPath:ftpPath]; [self.activityIndicator stopAnimating]; So UI updates occur when your method returns, and you won't see the update. What you need to do is startAnimating your activity indicator, then start your getListFromPath in another thread. When that method terminates, you call back your main thread telling it to stopAnimating the indicator. Use this methods: [NSObject performSelectorInBackground:withObject:] to start your getListFromPath thread, then when it's done, call [NSObject performSelectorOnMainThread:withObject:waitUntilDone:] to give the control back to the main thread, which will stop the spinner animation.

Related questions

0 votes
    i'm trying to get directory file listing from my ftp server using Chilkat library. In this case, i ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    The predicate in a where clause can involve Boolean operations such as and. The result of true and ... , Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    I want to put a settings icon to the right of a full-width button which when clicked opens an ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    In the following program, if I set the variable $foo to the value 1 inside the first if statement, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    The magnetic field intensity will be zero inside a conductor. State true/false. (a) True (b ... proposed by,electromagnetic theory engineering physics,electromagnetic theory nptel...
asked Nov 11, 2021 in Education by JackTerrance
0 votes
    EM waves do not travel inside metals. State True/False. (a) True (b) False This question ... proposed by,electromagnetic theory engineering physics,electromagnetic theory nptel...
asked Nov 6, 2021 in Education by JackTerrance
0 votes
    Which method is used to generate boolean random values in java? (a) nextBoolean() (b) randomBoolean() (c) ... Utility Classes of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    I am working on WPF application.I have bound my textblock to my button. I want to set foreground ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I am working on WPF application.I have bound my textblock to my button. I want to set foreground ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    According to the R language definition, the difference between & and && (correspondingly | and ||) is that the former ... OrElse in R? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    Derive a Canonical POS expression for a Boolean function F, represented by the following truth table : 1 A B C F 0 0 0 ... 1 0 1 1 1 1 Select the correct answer from above options...
asked Dec 23, 2021 in Education by JackTerrance
0 votes
    Convert the Boolean function, F(x, y, z) = ∏(0, 2, 6, 7) in sum of minterm form. Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    Express the Boolean Function, F (A, B, C) = AB + B’C’ in product of maxterm form. Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    Simplify the Boolean expression using algebraic method (A’+B)(A+B) Select the correct answer from above options...
asked Dec 12, 2021 in Education by JackTerrance
...