Hi, I’ve been lurking for awhile and I think I finally have a question that the FAQs don’t touch on.
I have a view controller with its own class and a UITextView widget. This is a loading screen. Data gets crunched and added to an array within a separate “Business” class, and I want this UITextView to update with the contents of each new member.
Because of the UI outlet scope, I obviously cannot update the TextView directly from my business class.
My solution has been to start a loop in the ViewDidAppear() function of my loading screen , which calls the business class function and then prints the contents of a global variable to my textview. Problem is, my loop is locking up the whole program and it either doesn’t try to print to the textview until after the loop has completed or isn’t calling the business class function at all, with no error messages. The program prints the initialized value of the global variable n times instead.
My question is, if you wanted a loop to run when you entered a view controller that calls a function in another class, waits for completion, and then updates a local textview, what kind of control structure would you use?
Right now I’m using a funky timer from stackoverflow as the loop, but I want the textview to update in real time not just with the contents of my globals every 1 second interval. The timer has got to go.
For reference I haven’t touched my app delegate. I was trying to keep this simple.
Thanks in advance