Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Handling a Notification

I want to be able to quit the app have some variables present when a notification is tapped

I was able to get the desired viewcontrollers to appear with the desired variables ie:

app running in background
notification pops up: How many wheels do bicycles have? loads NotiViewController with: Bicycles have 2 wheels.

while the app was running in the background, but if I quit the app the, Int variable, that selected the text for the body of the notification, gets lost and the desired viewcontroller loads but shows text that doesn't match with what was in the notification body. This is my current situation:

quits app
notification pops up: How many wheels do bicycles have? loads NotiViewController with: There are 48 states in the contiguous United States.

Is there a way to save the states of certain variables so there are ready to be plugged in where needed, just as if the user never quit the app?