# \[Solved\] iOS downloaded app crashes on data save using Stored variables

**URL:** <https://community.thunkable.com/t/solved-ios-downloaded-app-crashes-on-data-save-using-stored-variables/426251>\
**Category:** Questions about Thunkable X\
**Tags:** solved\
**Created:** [January 25, 2020, 2:37am UTC](https://community.thunkable.com/t/solved-ios-downloaded-app-crashes-on-data-save-using-stored-variables/426251 "2020-01-25T02:37:39Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [January 25, 2020, 2:37am UTC](https://community.thunkable.com/t/solved-ios-downloaded-app-crashes-on-data-save-using-stored-variables/426251/1 "2020-01-25T02:37:39Z")

</div>

app link: [Thunkable](https://x.thunkable.com/copy/4e58dddd5c9969ea48ebb61ab575515f)  
this is just the screen i am referencing from my larger app. all variables used in the “save behaviors” button are initialized on the same screen

I am trying to save a string to a variable. When I save a string, it causes the downloaded app to crash. On restart, the variable shows the value I attempted to save which is fine. The issue is that saving causes a glitch. I am hoping someone in the community can check this code out and perhaps the app and let me know if you see anything that would cause an error.

**Also** I should mention, if there is no text in the text inputs, the alerts work just fine and the app doesn’t crash. They tell the user to put some text into the text box and doesn’t save anything.

The weird part is that when I use the live companion app, this behavior does not occur. Only on the downloaded app.

I am on iOS 13 using both an iPhone and iPad.

 ![Screen Shot 2020-01-24 at 9.23.47 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/c/ccf190c76be2b099f18a19d173d8dbff3dcdb40f.png)

@domhnallohanlon had asked if the variables that I am saving to would have been initialized at this point and the answer is yes. They are initialized on this screen however they are referenced on a previous screen. That said, if they are empty on the previous screen, the user is sent to the ‘set up’ screen to set those variables with a text string.

this is a new issue. new to the last day or 2

**This is not happening on my android emulator or the live companion app. anybody that can help me please do! this is driving me nutz! I can’t figure it out.**

@tatiang per your request, sir! the initialization blocks

 ![Screen Shot 2020-01-24 at 10.44.14 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/1/b1c250d5bfce8a0d4cb07ca35c6fe74de7f26f04.png)

as an update. i took out the variables and i dont experience the same issue. i am going to try to move the initialization and setting as a generic string to a ‘splash’ screen and will update.

 ![Screen Shot 2020-01-24 at 10.49.48 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/1/f1900371200de8c90d75068634c64a8d4a992a28.png)

\*\*\*Update. when i initialize blocks on a splash screen and set them as a text variable, this fixes the crashing issue. (i actually deleted the original variables and set it as 1 variable with a list of text values) and now I am applying this to the bigger app and will get back with an update after downloaded and tested

here are the blocks i tested and will be implementing in my main app

 ![Screen Shot 2020-01-24 at 11.12.31 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/f/bffc90a0d2cf97661333a8441a4dcb95d3cbc193.png) ![Screen Shot 2020-01-24 at 11.11.50 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/0/f08148d4a29d60d31d04b41ce4910a2266be700d.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 25, 2020, 3:52am UTC](https://community.thunkable.com/t/solved-ios-downloaded-app-crashes-on-data-save-using-stored-variables/426251/2 "2020-01-25T03:52:08Z")

</div>

Post a screenshot of the initialize blocks for those variables. The _type_ is very important and it’s not shown above.

And if you’re initializing them to [no block] then what values are they set to the first time they are set to a value? Because I believe that then determines the type of variable they are from that point forward.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [January 25, 2020, 3:57am UTC](https://community.thunkable.com/t/solved-ios-downloaded-app-crashes-on-data-save-using-stored-variables/426251/3 "2020-01-25T03:57:19Z")

</div>

as always, thank you for your time and consideration!

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 25, 2020, 4:00am UTC](https://community.thunkable.com/t/solved-ios-downloaded-app-crashes-on-data-save-using-stored-variables/426251/4 "2020-01-25T04:00:32Z")

</div>

Oops! Stored variables don’t get initialized as a type. I forgot that! And you’re welcome… I do what I can.

So it may be an issue with how the variables are set to their first values. Because it’s not happening consistently across device/preview experiences, I can’t know that for sure but it’s a hunch.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [January 25, 2020, 4:02am UTC](https://community.thunkable.com/t/solved-ios-downloaded-app-crashes-on-data-save-using-stored-variables/426251/5 "2020-01-25T04:02:11Z")

</div>

> [@tatiang](#):
>
> an issue with how the variables

as an update. i took out the variables and i dont experience the same issue. i am going to try to move the initialization and setting as a generic string to a ‘splash’ screen and will update.

 ![Screen Shot 2020-01-24 at 10.49.48 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/1/f1900371200de8c90d75068634c64a8d4a992a28.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 25, 2020, 4:02am UTC](https://community.thunkable.com/t/solved-ios-downloaded-app-crashes-on-data-save-using-stored-variables/426251/6 "2020-01-25T04:02:17Z")

</div>

It looks like you’re storing a text input value for each of those Stored variables. If so, are there any special characters (e.g. punctuation) that you’re inputting?

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [January 25, 2020, 4:03am UTC](https://community.thunkable.com/t/solved-ios-downloaded-app-crashes-on-data-save-using-stored-variables/426251/7 "2020-01-25T04:03:18Z")

</div>

i haven’t been. just text. single letters for testing purposes.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 25, 2020, 4:04am UTC](https://community.thunkable.com/t/solved-ios-downloaded-app-crashes-on-data-save-using-stored-variables/426251/8 "2020-01-25T04:04:52Z")

</div>

When you had the variables included, were you seeing the last Alert in the list? If not, where was it crashing… which alert?

Edit: oh, nevermind… you’re right, they would only show if the input is empty.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [January 25, 2020, 4:07am UTC](https://community.thunkable.com/t/solved-ios-downloaded-app-crashes-on-data-save-using-stored-variables/426251/9 "2020-01-25T04:07:23Z")

</div>

so, the alerts showed if i left a text box blank only. i would see it then. if no text is blank, that’s when the crash occurs

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [January 25, 2020, 5:48am UTC](https://community.thunkable.com/t/solved-ios-downloaded-app-crashes-on-data-save-using-stored-variables/426251/10 "2020-01-25T05:48:05Z")

</div>

\*\*\*Solve

Though the variables are initialized, they still don’t like being saved for some reason without being manually set as a text variable. So I do that with this code. The first time the user visits this screen, the variables are set as a text string. Then any other time, this step is bypassed and the screen just opens up. problem solved!

 ![Screen Shot 2020-01-25 at 12.35.10 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/d/adfc0f9a3f9c08200df9bc53e540328063a87985.png)

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 11:45am UTC](https://community.thunkable.com/t/solved-ios-downloaded-app-crashes-on-data-save-using-stored-variables/426251/11 "2024-11-08T11:45:54Z")

</div>


