# Declare a constant?

**URL:** <https://forum.xojo.com/t/declare-a-constant/28354>\
**Category:** iOS\
**Created:** [November 29, 2015, 4:16pm UTC](https://forum.xojo.com/t/declare-a-constant/28354 "2015-11-29T16:16:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ulrich\_Bogun](https://forum.xojo.com/user_avatar/forum.xojo.com/ulrich_bogun/32/1864_2.png) [@Ulrich\_Bogun](https://forum.xojo.com/u/Ulrich_Bogun)\
**Post date:** [November 29, 2015, 4:16pm UTC](https://forum.xojo.com/t/declare-a-constant/28354/1 "2015-11-29T16:16:24Z")

</div>

Still in the works on UITableView, I stumbled upon this:

[quote]Default Dimension  
The default value for a given dimension.

Declaration  
SWIFT  
let UITableViewAutomaticDimension: CGFloat  
OBJECTIVE-C  
UIKIT\_EXTERN const CGFloat UITableViewAutomaticDimension;  
Constants  
UITableViewAutomaticDimension  
Requests that UITableView use the default value for a given dimension.

Available in iOS 5.0 and later.  
Discussion  
You return this value from UITableViewDelegate methods that request dimension metrics when you want UITableView to choose a default value. For example, if you return this constant in tableView:heightForHeaderInSection: or tableView:heightForFooterInSection:, UITableView uses a height that fits the value returned from tableView:titleForHeaderInSection: or tableView:titleForFooterInSection: (if the title is not nil).[/quote]

How would I declare it? I tried a variety of things, but none without a crash.

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [November 29, 2015, 4:18pm UTC](https://forum.xojo.com/t/declare-a-constant/28354/2 "2015-11-29T16:18:55Z")

</div>

you can create an app in Xcode which prints the value of the constant to console window.

---

<div class="post-metadata">

**Author:** ![Ulrich\_Bogun](https://forum.xojo.com/user_avatar/forum.xojo.com/ulrich_bogun/32/1864_2.png) [@Ulrich\_Bogun](https://forum.xojo.com/u/Ulrich_Bogun)\
**Post date:** [November 29, 2015, 4:25pm UTC](https://forum.xojo.com/t/declare-a-constant/28354/3 "2015-11-29T16:25:23Z")

</div>

Thanks, Christian! But no way in pure Xojo?

---

<div class="post-metadata">

**Author:** ![Eli\_Ott](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/5f8ce5/32.png) [@Eli\_Ott](https://forum.xojo.com/u/Eli_Ott)\
**Post date:** [November 29, 2015, 4:28pm UTC](https://forum.xojo.com/t/declare-a-constant/28354/4 "2015-11-29T16:28:41Z")

</div>

[code]Declare Function CFBundleGetBundleWithIdentifier Lib “CoreFoundation” (bundleID As CFStringRef) As Ptr  
Declare Function CFBundleGetDataPointerForName Lib “CoreFoundation” (bundle As Ptr,  
symbolName As CFStringRef) As Ptr

Static UIKitBundle As Ptr = CFBundleGetBundleWithIdentifier(“com.apple.UIKit”)  
Static UITableViewAutomaticDimension As Single = CFBundleGetDataPointerForName(UIKitBundle,  
“UITableViewAutomaticDimension”).Single[/code]

---

<div class="post-metadata">

**Author:** ![Ulrich\_Bogun](https://forum.xojo.com/user_avatar/forum.xojo.com/ulrich_bogun/32/1864_2.png) [@Ulrich\_Bogun](https://forum.xojo.com/u/Ulrich_Bogun)\
**Post date:** [November 29, 2015, 4:31pm UTC](https://forum.xojo.com/t/declare-a-constant/28354/5 "2015-11-29T16:31:32Z")

</div>

GetDataPointerForName! Sounds very good! Thanks, Eli!

Edit: Woo-Hoo!

---

<div class="post-metadata">

**Author:** ![Joe\_Ranieri](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@Joe\_Ranieri](https://forum.xojo.com/u/Joe_Ranieri)\
**Post date:** [November 30, 2015, 12:25am UTC](https://forum.xojo.com/t/declare-a-constant/28354/6 "2015-11-30T00:25:47Z")

</div>

> [@232693:@Christian Schmitz](#):
>
> you can create an app in Xcode which prints the value of the constant to console window.

Don’t do this. There’s generally no API contract for OS X and iOS frameworks that say that the contents of a constant will be compared and there are places where the pointers are compared directly.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:04pm UTC](https://forum.xojo.com/t/declare-a-constant/28354/7 "2020-10-29T18:04:50Z")

</div>


