Hello Blog-Viewers,
Welcome to my fourth week of working with ScrapZero. Last week I set a goal of completing the program by this past Tuesday. Unfortunately, time has past and I have yet to complete it.
I discovered something new about programming this week—threading. Apparently, in most computers, programs run operations simultaneously and do not always follow the order specified by the programmer. Logically, this would seem to speed up computer processes and it does.. But it definitely slowed down my process (of completing the program.)
So here is an example of multi-threading:
If I have two functions, “f1” and “f2”, I might choose to run “f1” before “f2”. Logically, in a generic programming language, one would write:
“run f1”
“run f2”
The problem is that “f2” might have already completed a task before “f1” finished. In my case, “f2” was highly dependent on the results of “f1” which basically made the program fail every time.
So what did I do about this? I learned how to use multi-threading in programs to my advantage. In the Swift programming language, there is a method of prioritizing events with a block of code that looks like this:
dispatch_async(qos, { () -> Void in
//code to be run goes here
}
//qos is another variable that defines how important the process is.
//qos is another variable that defines how important the process is.
I probably should not go into too much detail as these processes are still a brain teaser for me.
So I finally fixed my code and the app is running properly. Although the app is not complete, I am going to start building an interface for ScrapZero so that it can easily modify the JSON file that I mentioned in the last blog post. This way, I won’t have to be the one to update the information that is uploaded to the app.
Thank you for checking out my blog. I hope to have some serious results in soon.
Lorentz





