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-26-2010, 01:15 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default first time launch method?

is there a first time launch method that is called only the first time the app is opened. becuase i have to set some variables, but i want them to be able to change and not revert back to what i set them to.

i hope you understand

Thanks
sumosumo84 is offline   Reply With Quote
Old 10-26-2010, 01:24 PM   #2 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 651
kapps11 is on a distinguished road
Default

I answered a post with this exact same question a while ago, see if you can find it :P

Basically, the idea was to create a plist. When you first run the app, the plist wont exist, so all of the variables you try to recieve will be nil, NO, etc. the best way was to make a bool and save it using NSUserDefaults. retrieve that when your view controller loads, and if it is NO, then that is the first time the app has been run. make sure you set it to yes later
kapps11 is offline   Reply With Quote
Old 10-26-2010, 02:00 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default

ok but how do i set the BOOL to NO without having it be no again the second time it is launched
sumosumo84 is offline   Reply With Quote
Old 10-26-2010, 02:43 PM   #4 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 651
kapps11 is on a distinguished road
Default

ok lets see here...
in your viewdidLoad, or wherever you want it
Code:
BOOL hasRunBefore = [[NSUserDefaults standardUserDefaults] boolForKey:@"FirstRun"];
if (hasRunBefore) {
****NOT the first time
}
else if (!hasRunBefore) {
****DO YOUR SETUP HERE
}
I think that should work. I wrote it off the top of my head (im not on my mac) so there may be some typos, but thats the idea
kapps11 is offline   Reply With Quote
Old 10-26-2010, 02:50 PM   #5 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 327
thomashw is on a distinguished road
Default

Use NSUserDefaults to determine whether it's the first launch.

On first launch, simply set a bool (or something else if you prefer) using the setBool:forKey: method. If it doesn't exist yet when your app launches, you know it's the first launch.
thomashw is offline   Reply With Quote
Old 10-26-2010, 04:01 PM   #6 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 651
kapps11 is on a distinguished road
Default

exactly, im just too sleepy to articulate it lol
kapps11 is offline   Reply With Quote
Old 10-26-2010, 04:21 PM   #7 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 327
thomashw is on a distinguished road
Default

Quote:
Originally Posted by kapps11 View Post
exactly, im just too sleepy to articulate it lol
Woops, I didn't even look at your post before I wrote mine.
thomashw is offline   Reply With Quote
Old 10-26-2010, 05:12 PM   #8 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default

ok thanks, i will see if these work and get back to you!
sumosumo84 is offline   Reply With Quote
Old 10-26-2010, 05:26 PM   #9 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default

thanks guys so much, i will probably make a video on this because i am probably not the only one having trouble!

don't worry i will give you guys credit!
sumosumo84 is offline   Reply With Quote
Old 10-26-2010, 08:02 PM   #10 (permalink)
Registered Member
 
Join Date: Aug 2009
Location: Tasmania, Australia
Posts: 195
Son of a Beach is on a distinguished road
Default

Rather than just saving a BOOL, I actually save that application bundle's version number string into defaults.

This provides some future proofing so that not only can you check if the app has been run before, you can check which version was last run. Sometimes this information is very useful indeed.
Son of a Beach is offline   Reply With Quote
Reply

Bookmarks

Tags
code, launch, method, time

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: 326
14 members and 312 guests
7twenty7, chiataytuday, condor304, Creativ, Domele, dreamdash3, laureix68, LEARN2MAKE, mistergreen2011, mottdog, palme2elie, Paul Slocum, schmallegory
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,660
Threads: 94,118
Posts: 402,895
Top Poster: BrianSlick (7,990)
Welcome to our newest member, laureix68
Powered by vBadvanced CMPS v3.1.0

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