Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-15-2011, 05:58 AM   #1 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 1
kamaleshj is on a distinguished road
Default How to use device clock to sync with app

Hi

I'm developing an app that will present a message to the iPhone/iPad user each day. One message will be presented from this database on each new day of the calendar year from the time the app is installed on the device. How do i make the program to recognize each new day as the app should retrieve one message from the database per day.. or how do i make the program to call a new message every time a day has begun??


Any help will be really appreciated... i'm still in the learning stages of iphone development.. so please guide me...


Thanks!!
kamaleshj is offline   Reply With Quote
Old 10-15-2011, 09:48 AM   #2 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by kamaleshj View Post
Hi

I'm developing an app that will present a message to the iPhone/iPad user each day. One message will be presented from this database on each new day of the calendar year from the time the app is installed on the device. How do i make the program to recognize each new day as the app should retrieve one message from the database per day.. or how do i make the program to call a new message every time a day has begun??


Any help will be really appreciated... i'm still in the learning stages of iphone development.. so please guide me...


Thanks!!

Take a look at NSCalendar, NSDate, and NSDateComponents. Unless you want to support localizations that use non-roman calendars, you just use a Gregorian calendar object.

There are methods in NSCalendar that let you take an NSDate and convert it to components like month/day/year.

What I would do is to create a Gregorian calendar object. I'd use that to calculate the month/day/year of the first launch, and save that to NSUserDefaults.

I would then set up the app so that on every launch (or return to foreground, since that's what you usually get) I would calculate the day/month/year of the current date. I'd compare that to a "currentDay" entry in user defaults. If there was no current day record, or today's value is greater, I'd update the message.

After deciding if the current day is greater than the saved current day, I'd save the new day/month/year value to a "currentDay" record in user defaults.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Reply

Bookmarks

Tags
calendar, database, timer

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 409
16 members and 393 guests
13dario13, 7twenty7, buggen, eski, EvilElf, glenn_sayers, j.b.rajesh@gmail.com, LunarMoon, morterbaher, n00b, pbart, QuantumDoja, sacha1996, Sami Gh, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,673
Threads: 94,122
Posts: 402,906
Top Poster: BrianSlick (7,990)
Welcome to our newest member, morterbaher
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:25 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0