optimizing my app

i have an app that is just a menu extra in the menu bar. it updates info from the internet and fills it into menu items in the menu extra, so its constantly updating and the app in general is very laggy due to the constant updating. it updates using the on idle handler. because of this updating sometimes you try to click the menu extra and it doesnt open because it is running the on idle handler. does anyone have any ideas on how i can possibly make the app run a little smoother and not be so laggy.


So your downloading stuff from the internet, and I assume that’s what is holding up the program. So the question is how can you download differently such that it doesn’t hold you up.

Are you using curl to download? If so then you’re using do shell script commands. And if that’s the case then you can issue your download command and not wait for the results. You can send the process to the background such that control is immediately returned to your script rather than waiting for results. The question then is how to transfer the results from curl to your program. Maybe you can write results to a file and read them in when you need them. If you have 2 files that curl writes to (because one of the files may be busy when you try to read it) in alternating fashion then you will always be assured of having a file that you can read from. Just put the read command in a try block, and if the read fails then read from the other file. Once you read the file, just parse the information and write it to your menu. That shouldn’t take much time.

But of course I don’t know any of the details so I’m just guessing. You have to tell more about what goes on in the on idle handler.

Also, I was just reading about NSMenu in the developer docs. Your application is a menu after all so it applies. What they said was that you shouldn’t constantly update your menu because of performance reasons. They say to only update it using the menuNeedsUpdate: delegate which only gets called just before the menu displays itself. I think that translates to applescript with the ‘update menu item’ handler… but I’m not positive.

it does use curl and when i get some time i’ll try using that handler you mentioned. thanks.