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 07-05-2011, 10:18 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 3
hiddesteenbeek is on a distinguished road
Default change a text by date

i have a question: i want to create an app that has a different text at the screen everyday by date. so for example:
on 5 july 2011: hi this is day 1
on 6 july 2011: hi this looks boring.
can someone please help me, thank you.

sorry for my english, i am dutch
hiddesteenbeek is offline   Reply With Quote
Old 07-05-2011, 10:29 AM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

you can retrieve the current date with
Code:
NSDate *today = [NSDate date];
now you can choose the right phrase from an array (depending on the number of the day or what you prefer)
__________________
dany_dev is offline   Reply With Quote
Old 07-05-2011, 11:16 AM   #3 (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 hiddesteenbeek View Post
i have a question: i want to create an app that has a different text at the screen everyday by date. so for example:
on 5 july 2011: hi this is day 1
on 6 july 2011: hi this looks boring.
can someone please help me, thank you.

sorry for my english, i am dutch
You need to provide more information. Where would these strings come from? Would they be stored in a file somewhere? Do you want to pick them randomly, or do you want to display them in order from the beginning to the end of a list of messages?

How do you decide which is day 1? If you assign 5 July 2011 as day 1, and have 200 strings, what happens when you release your app to the store, 201 days later? At that point your app is out of strings.

Without knowing more about what you want to do, I can only point you at the system components that you need.

The NSCalendar class lets you calculate the difference between 2 dates in any units you want. If 5 July is your day 1, you could create an NSDate that represents 5 July, and then use the NSCalendar method components:fromDate:toDateptions: to calculate the number of days from your 5 July date to the current date. You could then use that day number as an index into a table of message strings, if that's what you wanted.

Take a look at the XCode documentation on that method. It includes sample code that shows how to calculate the number of months and days between 2 dates. It could be easily modified to calculate the number of days between 2 dates instead.
__________________
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
Old 07-05-2011, 04:26 PM   #4 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 3
hiddesteenbeek is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
You need to provide more information. Where would these strings come from? Would they be stored in a file somewhere? Do you want to pick them randomly, or do you want to display them in order from the beginning to the end of a list of messages?

How do you decide which is day 1? If you assign 5 July 2011 as day 1, and have 200 strings, what happens when you release your app to the store, 201 days later? At that point your app is out of strings.

Without knowing more about what you want to do, I can only point you at the system components that you need.

The NSCalendar class lets you calculate the difference between 2 dates in any units you want. If 5 July is your day 1, you could create an NSDate that represents 5 July, and then use the NSCalendar method components:fromDate:toDateptions: to calculate the number of days from your 5 July date to the current date. You could then use that day number as an index into a table of message strings, if that's what you wanted.

Take a look at the XCode documentation on that method. It includes sample code that shows how to calculate the number of months and days between 2 dates. It could be easily modified to calculate the number of days between 2 dates instead.
those string can be in a .txt file or something that actually doesn't matter.
there would be 260 strings and they would just come in a specific order and when it comes to string 260 it would start with string 1 again.
hiddesteenbeek is offline   Reply With Quote
Old 07-05-2011, 06:00 PM   #5 (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 hiddesteenbeek View Post
those string can be in a .txt file or something that actually doesn't matter.
there would be 260 strings and they would just come in a specific order and when it comes to string 260 it would start with string 1 again.
Take a look at the components: fromDate: toDate: options: NSCalendar method I mentioned in my previous post. That would let you figure out the number of days that have elapsed since the first time the app was run. You would then use that index to index into your array of strings.

The tutorial in my signature for creating random, non-repeating text shows how to take a text file and split each line of the file into a separate entry in an array.

Those two things should let you do what you want.


Duncan
__________________
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
Old 07-06-2011, 04:17 AM   #6 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 3
hiddesteenbeek is on a distinguished road
Default

okay thank you very much.
hiddesteenbeek is offline   Reply With Quote
Old 09-24-2011, 08:13 AM   #7 (permalink)
Registered Member
 
Join Date: Sep 2011
Posts: 1
diva123 is on a distinguished road
Default hello,

for display message as per youur choice first you need to decide which date define what message.

for that you need to use the NSCalendar class as well as NSCalendar method. and define message as per your requiement.

After this you have one index as per your requirement and you can also use this index into your array string.........

Last edited by diva123; 09-28-2011 at 11:16 AM.
diva123 is offline   Reply With Quote
Reply

Bookmarks

Tags
app, date, dutch, text

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: 353
9 members and 344 guests
apatsufas, chemistry, lendo, leostc, Leslie80, lzwasyc, MarkC, SamorodovAlex, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,664
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Leslie80
Powered by vBadvanced CMPS v3.1.0

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