academyofrock
Code is Art
Profile
Posts: 7
Reg: Sep 11, 2012
Gillingham
70
09/11/12 08:09 AM (13 years ago)

Adding a 24 hour updating command in Xcode

My son is building an i Phone app using Xcode. The app offers daily advice and therefore needs to 'roll over' to a new 'page' every 24 hours. I have 365 pieces of advice but he has been unable to make it advance. Any ideas on how to code the update every 24 hours?
 
academyofrock
Code is Art
Profile
Posts: 7
Reg: Sep 11, 2012
Gillingham
70
like
09/11/12 08:10 AM (13 years ago)
I appear to have added this twice - not sure how I did that and don't seem to be able to delete - apologies
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
09/11/12 09:43 AM (13 years ago)
No worries about the additional post. I can think of a few ways to do this. -Have the phone check it's internal date before determing which screen to show. Screen, as in which one of the screens setup in the config.txt file. Not sure what type of content this is? -Use only ONE screen, connect it to a URL and force it to refresh each time. This screen would make a URL request to the URL for the daily content. Your backend script would determine what content to show. This method would require the app to be online or it would not get the new screen. In the first method, you'll need to figure out where to customize the code a bit to launch the screen for the right day. Without knowing more about how it's setup (menu, buttons, etc) it will be tough to recommend the best approach? I'm thinking a menu item with a "daily content" label...tapping that button would run a little routine to check the date before loading the proper screen. Have a look at the "rowDidSelect" method in the menu plugin you're using, that's where you'll do the math to determine what day it is before finding the "screen id" of the appropriate content in your JSON.
 
academyofrock
Code is Art
Profile
Posts: 7
Reg: Sep 11, 2012
Gillingham
70
like
09/11/12 09:50 AM (13 years ago)
Thank you David - this is most helpful. I like the first option best as you point out that it is independent of being online etc. I will get my son to start working on this now. He is just about to start a computer science degree so fantastic timing. My thanks Peter
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
09/11/12 11:07 AM (13 years ago)
Subscribing to this thread in the hopes that you'll post the final solution your son comes up with! Could be very useful in any number of apps! Mark
 
academyofrock
Code is Art
Profile
Posts: 7
Reg: Sep 11, 2012
Gillingham
70
like
09/11/12 11:22 AM (13 years ago)
OK - I will keep you posted
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
09/11/12 02:06 PM (13 years ago)
You could use an html doc with javascript. This example would display a different jpg based on the current date (ie. picture911.jpg, picture912.jpg, etc) In the head, you'd use something like this: <script type="text/javascript" language="JavaScript"> FirstPart = '<img border="1" src="picture'; LastPart = '.jpg">'; function printImage() { var d = new Date(); var Today = d.getDate(); var Month = d.getMonth(); document.write(FirstPart + Month + Today + LastPart); } </script> Then in the body: <script type="text/javascript" language="JavaScript"><!-- printImage(); //--></script> You could modify this to display text or other files as well.
 
academyofrock
Code is Art
Profile
Posts: 7
Reg: Sep 11, 2012
Gillingham
70
like
09/12/12 09:42 AM (13 years ago)
Thank you also for this suggestion - I will let you know which way we intend to go
 
academyofrock
Code is Art
Profile
Posts: 7
Reg: Sep 11, 2012
Gillingham
70
like
09/19/12 09:21 AM (13 years ago)
What we have done is to develop the content into an excel spreadsheet and then call on particular pieces of data by the day concerned. Thanks for the help
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.