Help needed with TSNet and optimization

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

Help needed with TSNet and optimization

Post by jekyllandhyde » Wed Jan 18, 2017 10:24 am

I'm in the final stages of testing my iOS App which uses a REST API to download live data once every second or so. The data expires after the screen updates. I've realized that PUT is synchronous so I'm hoping to speed things up and stop the occasional screen freezing by going the asynchronous route, but I don't understand how the TSNET library and commands work. Here's what I've done so far.

Code: Select all

--original code (only needed three lines) but is synchronous
on mouseUp
put "http://"&tikipp&"/urlsample/" into talldata
put URL talldata into talldata
put jsonimport(talldata) into gArray
end mouseUp

---replaced by asynchronous approach:
on mouseUp
put "http://"&tikipp&"/urlsample/" into talldata
load URL talldata with message "downloadComplete"
end mouseUP

on downloadComplete pURL, pURLStatus
   if pURLStatus is "cached" then
      put URL pURL into talldata2
      put jsonimport(talldata2) into gArray
      end if
      unload url pURL
end downloadComplete
------
So I guess the main question is should I stick with my second approach, assuming the code is correct or further optimize with TSNet - but how?

thx in advance.

Post Reply

Return to “iOS Deployment”