# Global vs. local variables in iOS?

**URL:** <https://community.thunkable.com/t/global-vs-local-variables-in-ios/7750>\
**Category:** Questions about Thunkable X\
**Created:** [September 17, 2017, 4:48pm UTC](https://community.thunkable.com/t/global-vs-local-variables-in-ios/7750 "2017-09-17T16:48:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BillG](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@BillG](https://community.thunkable.com/u/BillG)\
**Post date:** [September 17, 2017, 4:48pm UTC](https://community.thunkable.com/t/global-vs-local-variables-in-ios/7750/1 "2017-09-17T16:48:55Z")

</div>

Hi All,

[Some corrections below.]

Is there a way to create a global variable in iOS? Placing a variable outside of a block (which should be global scope) results in it being grayed out.

![](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/2X/2/2cde730b3be605764eb99c691935e594d22260aa.png)

Thanks!  
BillG

---

<div class="post-metadata">

**Author:** ![BillG](https://avatars.discourse-cdn.com/v4/letter/b/d78d45/32.png) [@BillG](https://community.thunkable.com/u/BillG)\
**Post date:** [September 17, 2017, 6:56pm UTC](https://community.thunkable.com/t/global-vs-local-variables-in-ios/7750/2 "2017-09-17T18:56:05Z")

</div>

Oops, actually the variables look like they are global, not local as I first thought:

![](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/2X/a/ab8274b764cc6a04745a82a7ecfd3d495686aa3b.png)

Clicking Button1 sets the variable globalScopeProbably to “Button1”. Then, clicking Button2 sets it to “Button2”. This indicates that globalScopeProbably is global in scope, not local.

Does Thunkable for iOS support local variables? If so, how?

Thanks!  
BillG

---

<div class="post-metadata">

**Author:** ![albert](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/albert/32/4077_2.png) [@albert](https://community.thunkable.com/u/albert)\
**Post date:** [September 18, 2017, 6:12pm UTC](https://community.thunkable.com/t/global-vs-local-variables-in-ios/7750/3 "2017-09-18T18:12:47Z")

</div>

Hi there. We don’t yet support initializing variables. We do support local variables within functions:

![](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/2X/0/0767750d0f95e7e1b22727741037d9dcbc76336f.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, 12:06pm UTC](https://community.thunkable.com/t/global-vs-local-variables-in-ios/7750/4 "2024-11-08T12:06:14Z")

</div>


