开发者

How to run the program regularly?

开发者 https://www.devze.com 2023-01-12 10:56 出处:网络
I want to ask a question about the iPhone application. I am writing a program which can upload some information to a server. However, the user has to click a button before the upload. Therefore, is it

I want to ask a question about the iPhone application. I am writing a program which can upload some information to a server. However, the user has to click a button before the upload. Therefore, is it possible for the a开发者_如何学Pythonpplication to upload the data to server regularly after the user only click one time of the button?

It means that the app will upload the data at 12:00 p.m, 12:00 am .... Thank you.


It is possible if and only if your app run all the time. Otherwise, if users quit your app then you cannot set and run any code inside your app. You also cannot set any timer inside iphone to run your app.

So, if the user open your app in the time. Then you can use NSTimer to schedule the time to upload your data. If user quit, you stored the last time you upload data, then when user open your app again, you check for the last time uploading and if it is too old, you upload data again. + (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds invocation:(NSInvocation *)invocation repeats:(BOOL)repeats

More here


Please correct me if I'm wrong, but I do not believe this is possible using the current official SDK.


I dont know why you need to send the data to webserver regularly.

Suppose if you are not running the application for 7 days, the data is not gonna change in iPhone den whats the reason to re upload the unchanged data.

So suggest you to upload at the time of exiting the application or at the time of starting the application What ever you prefers.

Happy Coding...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号