<div class="meta" robots="noindex">

</div>

Class

# iOSBlock

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2021r3. Please use `ObjCBlock</api/macos/objcblock>` as a replacement.

</div>

## Description

Used when callings declares that require Obj-C blocks. An <span class="title-ref">iOSBlock</span> is created from a Delegate and in turn creates an Objective-C block that will call into the delegate. This Objective-C block is retrieved from the Handle property and passed into declares.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                      | Type                                        | Read-Only | Shared |
|---------------------------|---------------------------------------------|-----------|--------|
| `Handle<iosblock.handle>` | `Ptr</api/data_types/additional_types/ptr>` | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                 | Parameters                                                       | Returns | Shared |
|--------------------------------------|------------------------------------------------------------------|---------|--------|
| `Constructor<iosblock.constructor0>` | theDelegate As `Object</api/data_types/additional_types/object>` |         |        |

## Property descriptions

<div id="iosblock.handle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSBlock.Handle

**Handle** As `Ptr</api/data_types/additional_types/ptr>`

Gets the Objective-C block.

This property is read-only.

## Method descriptions

<div id="iosblock.constructor0">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

iOSBlock.Constructor

**Constructor**(theDelegate As `Object</api/data_types/additional_types/object>`)

<div class="note">

<div class="title">

Note

</div>

`Constructors</api/language/constructor>` are special methods called when you create an object with the `New</api/language/new>` keyword and pass in the parameters above.

</div>

Used to supply the delegate to create for the block.

## Sample code

The openURL command can be called with a series of Declares, the last of which requires a Block. Here are the Declares:

``` xojo
Public Function ShowURL(url As String) as Boolean
  ' NSString* launchUrl = @"http://www.xojo.com/";
  ' [[UIApplication sharedApplication] openURL:[NSURL URLWithString: launchUrl]];

  Declare Function NSClassFromString Lib "Foundation" (name As CFStringRef) As Ptr
  Declare Function sharedApplication Lib "UIKit" Selector "sharedApplication" (obj As Ptr) As Ptr
  Dim sharedApp As Ptr = sharedApplication(NSClassFromString("UIApplication"))

  ' https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/#//apple_ref/occ/clm/NSURL/URLWithString:
  Declare Function URLWithString Lib "Foundation" Selector "URLWithString:" ( id As Ptr, URLString As CFStringRef ) As Ptr
  Dim nsURL As Ptr = URLWithString(NSClassFromString("NSURL"), url)

  ' https://developer.apple.com/Library/ios/documentation/UIKit/Reference/UIApplication_Class/index.html#//apple_ref/occ/instm/UIApplication/openURL:
  Declare Function openURL Lib "UIKit" Selector "openURL:options:completionHandler:" (id As Ptr, nsurl As Ptr, options As Ptr, handler As Ptr) As Boolean

  Dim b As New iOSBlock(AddressOf URLResult)

  Return openURL(sharedApp, nsURL, Nil, b.Handle)
End Function
```

## Compatibility

iOS projects on the iOS operating system.

## See also

`Object</api/data_types/additional_types/object>` parent class; `Declare</api/language/declare>` command, `Ptr</api/data_types/additional_types/ptr>` data type
