Mac Developer Library

Developer

IOBluetoothServiceBrowserController Class Reference

Options
Deployment Target:

On This Page
Language:

IOBluetoothServiceBrowserController

Inheritance


Conforms To


Import Statement


Swift

import IOBluetoothUI

Objective-C

@import IOBluetoothUI;

Availability


Available in OS X v10.2 and later.

A NSWindowController subclass to display a window to search for and perform SDP queries on bluetooth devices within range.

This NSWindowController subclass will bring up a generic Bluetooth search and SDP browsing window allowing the user to find devices within range, perform SDP queries on a particular device, and select a SDP service to connect to. The client application can provide NSArrays of valid service UUIDs to allow, and an NSArray of valid device types to allow. The device type filter is not yet implemented.

  • Adds a UUID to the list of UUIDs that are used to validate the user's selection.

    Declaration

    Swift

    func addAllowedUUID(_ allowedUUID: IOBluetoothSDPUUID!)

    Objective-C

    - (void)addAllowedUUID:(IOBluetoothSDPUUID *)allowedUUID

    Parameters

    allowedUUID

    UUID that a device may contain to be selected

    Discussion

    The user's device selection gets validated against the UUIDs passed to -addAllowedUUID: addAllowedUUIDArray:. Each call to those methods essentially adds a filter that the selected device gets validated with. If any of the filters match, the device is considered valid. If they all fail, the device is not valid and the user is presented with an error code that the device does not support the required services. The UUID passed to -addAllowedUUID: is the only UUID that must be present in the device's SDP service records. Alternatively, all of the UUIDs in the UUID array passed to -addAllowedUUIDArray must be present.

    NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Adds an array of UUIDs to the list of UUIDs that are used to validate the user's selection.

    Declaration

    Swift

    func addAllowedUUIDArray(_ allowedUUIDArray: [AnyObject]!)

    Objective-C

    - (void)addAllowedUUIDArray:(NSArray *)allowedUUIDArray

    Parameters

    allowedUUIDArray

    An NSArray of UUIDs that all must be present in a device for it to be selectable.

    Discussion

    The user's device selection gets validated against the UUIDs passed to -addAllowedUUID: addAllowedUUIDArray:. Each call to those methods essentially adds a filter that the selected device gets validated with. If any of the filters match, the device is considered valid. If they all fail, the device is not valid and the user is presented with an error code that the device does not support the required services. The UUID passed to -addAllowedUUID: is the only UUID that must be present in the device's SDP service records. Alternatively, all of the UUIDs in the UUID array passed to -addAllowedUUIDArray must be present.

    NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Runs the service browser panel as a sheet on the target window.

    Declaration

    Swift

    func beginSheetModalForWindow(_ sheetWindow: NSWindow!, modalDelegate modalDelegate: AnyObject!, didEndSelector didEndSelector: Selector, contextInfo contextInfo: UnsafeMutablePointer<Void>) -> IOReturn

    Objective-C

    - (IOReturn)beginSheetModalForWindow:(NSWindow *)sheetWindow modalDelegate:(id)modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo

    Parameters

    sheetWindow

    NSWindow to attach the service browser panel to as a sheet.

    modalDelegate

    Delegate object that gets sent the didEndSelector when the sheet modal session is finished.

    didEndSelector

    Selector sent to the modalDelegate when the sheet modal session is finished.

    contextInfo

    User-definied value passed to the modalDelegate in the didEndSelector.

    Return Value

    Returns kIOReturnSuccess if the sheet modal session was started.

    Discussion

    This function works the same way as -[NSApplication beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:]. The didEndSelector has a similar prototype as in NSApplication except that the first argument is the IOBluetoothServiceBrowserController object instead of the window: -(void)sheetDidEnd:(IOBluetoothServiceBrowserController *)controller returnCode:(int)returnCode contextInfo:(void *)contextInfo. The returnCode parameter will either be kIOBluetoothUISuccess or kIOBluetoothUIUserCancelledErr as described in -runModal.

    NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Resets the controller back to the default state where it will accept any device the user selects.

    Declaration

    Swift

    func clearAllowedUUIDs()

    Objective-C

    - (void)clearAllowedUUIDs

    Discussion

    NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • discover: - discover: (OS X v10.5)

    Invoke an already created window controller to display, and run the modal dialog.

    Declaration

    Objective-C

    - (IOReturn)discover:(IOBluetoothSDPServiceRecord **)outRecord

    Parameters

    outRecord

    Pointer to a (IOBluetoothSDPServiceRecord *) object. This will get allocated and returned to the client if the user selects a service.

    Return Value

    IOReturn - * kIOReturnSuccess - on successful completion. * kCanceledErr - User canceled.

    Discussion

    This method will run the IOBluetoothServiceBrowserController browser window modally.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.5.

  • Invoke an already created window controller to display, and run the modal dialog.

    Declaration

    Objective-C

    - (IOReturn)discoverAsSheetForWindow:(NSWindow *)sheetWindow withRecord:(IOBluetoothSDPServiceRecord **)outRecord

    Parameters

    sheetWindow

    The window to use for the anchor of the sheet..

    outRecord

    Pointer to a (IOBluetoothSDPServiceRecord *) object. This will get allocated and returned to the client if the user selects a service.

    Return Value

    IOReturn - * kIOReturnSuccess - on successful completion. * kCanceledErr - User canceled.

    Discussion

    This method will run the IOBluetoothServiceBrowserController browser window as a sheet for the window passed to it in sheetWindow.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.5.

  • Invoke an already created window controller to display, and run the modal dialog.

    Declaration

    Objective-C

    - (IOReturn)discoverWithDeviceAttributes:(IOBluetoothDeviceSearchAttributes *)deviceArray serviceList:(NSArray *)serviceArray serviceRecord:(IOBluetoothSDPServiceRecord **)outRecord

    Parameters

    deviceArray

    A NSArray of valid device type objects to allow. Not implemented yet.

    serviceArray

    A NSArray of valid UUIDs to allow. The array should contain NSData objects specifying the UUID to allow. We currently only support 16-bit short UUID forms, but will allow for any of the 16, 32 or full 128-bit UUID forms.

    outRecord

    Pointer to a (IOBluetoothSDPServiceRecord *) object. This will get allocated and returned to the client if the user selects a service.

    Return Value

    IOReturn - * kIOReturnSuccess - on successful completion. * kCanceledErr - User canceled.

    Discussion

    This method will run the IOBluetoothServiceBrowserController browser window as a sheet for the window passed to it in sheetWindow.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.5.

  • Returns the description text that appears in the device selector panel (i.e. what was set in -setDescriptionText:).

    Declaration

    Swift

    func getDescriptionText() -> String!

    Objective-C

    - (NSString *)getDescriptionText

    Return Value

    Returns the description text of the device selector panel.

    Discussion

    NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Returns the option bits that control the panel's behavior.

    Declaration

    Swift

    func getOptions() -> IOBluetoothServiceBrowserControllerOptions

    Objective-C

    - (IOBluetoothServiceBrowserControllerOptions)getOptions

    Return Value

    Returns the option bits set by setOptions:

    Discussion

    NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Returns the title of the default/select button in the device selector panel (i.e. what was set in -setPrompt:).

    Declaration

    Swift

    func getPrompt() -> String!

    Objective-C

    - (NSString *)getPrompt

    Return Value

    Returns the default button title of the device selector panel.

    Discussion

    NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Returns the result of the user's selection.

    Declaration

    Swift

    func getResults() -> [AnyObject]!

    Objective-C

    - (NSArray *)getResults

    Return Value

    Returns an NSArray of IOBluetoothSDPServiceRecord objects corresponding to the user's selection. If the user cancelled the panel, nil will be returned.

    Discussion

    There will only be results if the panel has been run, the user has successfully made a selection and that selection has been validated. If kIOBluetoothUISuccess was returned for the session, there should be valid results. Currently only a single device is allowed to be selected, so the results array will only contain one object. However in the future multiple selection will be supported.

    NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Returns the search attributes that control the panel's search/inquiry behavior.

    Declaration

    Swift

    func getSearchAttributes() -> UnsafePointer<IOBluetoothDeviceSearchAttributes>

    Objective-C

    - (const IOBluetoothDeviceSearchAttributes *)getSearchAttributes

    Return Value

    Returns the search attributes set by setSearchAttributes:

    Discussion

    NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Returns an IOBluetoothServiceBrowserControllerRef representation of the target IOBluetoothServiceBrowserController object.

    Declaration

    Swift

    func getServiceBrowserControllerRef() -> Unmanaged<IOBluetoothServiceBrowserController>!

    Objective-C

    - (IOBluetoothServiceBrowserControllerRef)getServiceBrowserControllerRef

    Return Value

    Returns an IOBluetoothServiceBrowserControllerRef representation of the target IOBluetoothServiceBrowserController object.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Returns the title of the device selector panel (i.e. what was set in -setTitle:).

    Declaration

    Swift

    func getTitle() -> String!

    Objective-C

    - (NSString *)getTitle

    Return Value

    Returns the title of the device selector panel.

    Discussion

    NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Runs the service browser panel in a modal session to allow the user to select a service on a Bluetooth device.

    Declaration

    Swift

    func runModal() -> Int32

    Objective-C

    - (int)runModal

    Return Value

    Returns kIOBluetoothUISuccess if a successful, validated service selection was made by the user. Returns kIOBluetoothUIUserCanceledErr if the user cancelled the panel. These return values are the same as NSRunStoppedResponse and NSRunAbortedResponse respectively. They are the standard values used in a modal session.

    Discussion

    The controller will use the panel attributes to filter what devices the user sees. The allowed UUIDs will be used to validate the selection the user makes. The user will only be able to select services that match the allowed UUIDs. Only when a selection has been validated (or the panel cancelled), will this method return.

    NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Sets the description text that appears in the device selector panel.

    Declaration

    Swift

    func setDescriptionText(_ descriptionText: String!)

    Objective-C

    - (void)setDescriptionText:(NSString *)descriptionText

    Parameters

    descriptionText

    String that appears in the description section of the device selector panel.

    Discussion

    The description text should be localized for best user experience.

    NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Modify the options for the window controller.

    Declaration

    Swift

    func setOptions(_ inOptions: IOBluetoothServiceBrowserControllerOptions)

    Objective-C

    - (void)setOptions:(IOBluetoothServiceBrowserControllerOptions)inOptions

    Parameters

    inOptions

    Bit field to set the options to.

    Return Value

    None.

    Discussion

    This method will set the options for the browser to new values.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Sets the title of the default/select button in the device selector panel.

    Declaration

    Swift

    func setPrompt(_ prompt: String!)

    Objective-C

    - (void)setPrompt:(NSString *)prompt

    Parameters

    prompt

    String that appears in the default/select button in the device selector panel.

    Discussion

    The prompt text should be localized for best user experience.

    NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Sets the search attributes that control the panel's search/inquiry behavior.

    Declaration

    Swift

    func setSearchAttributes(_ searchAttributes: UnsafePointer<IOBluetoothDeviceSearchAttributes>)

    Objective-C

    - (void)setSearchAttributes:(const IOBluetoothDeviceSearchAttributes *)searchAttributes

    Parameters

    searchAttributes

    Attributes to control the panel's inquiry behavior.

    Discussion

    The device search attributes control the inquiry behavior of the panel. They allow only devices that match the specified attributes (i.e. class of device) to be displayed to the user. Note that this only covers attributes returned in an inquiry result and not actual SDP services on the device.

    NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Sets the title of the panel when not run as a sheet.

    Declaration

    Swift

    func setTitle(_ windowTitle: String!)

    Objective-C

    - (void)setTitle:(NSString *)windowTitle

    Parameters

    windowTitle

    Title of the device selector panel.

    Discussion

    The panel title should be localized for best user experience.

    NOTE: This method is only available in Mac OS X 10.2.4 (Bluetooth v1.1) or later.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Declaration

    Objective-C

    + (IOReturn)browseDevices:(IOBluetoothSDPServiceRecord **)outRecord options:(IOBluetoothServiceBrowserControllerOptions)inOptions

    Parameters

    outRecord

    Pointer to a (IOBluetoothSDPServiceRecord *) object. This will get allocated and returned to the client if the user selects a service.

    inOptions

    For future expansion. Currently no options defined.

    Return Value

    IOReturn -

    * kIOReturnSuccess - on successful completion.

    * kCanceledErr - User canceled.

    Discussion

    This method allocates and runs the browser window as a modal window waiting for the user to either select a service, or cancel the browser window.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.5.

  • Declaration

    Objective-C

    + (IOReturn)browseDevicesAsSheetForWindow:(IOBluetoothSDPServiceRecord **)outRecord options:(IOBluetoothServiceBrowserControllerOptions)inOptions window:(NSWindow *)inWindow

    Parameters

    outRecord

    Pointer to a (IOBluetoothSDPServiceRecord *) object. This will get allocated and returned to the client if the user selects a service.

    inOptions

    For future expansion. Currently no options defined.

    inWindow

    The window to be used as the anchor of the sheet.

    Return Value

    IOReturn - * kIOReturnSuccess - on successful completion. * kCanceledErr - User canceled.

    Discussion

    This method will allocate and run the IOBluetoothServiceBrowserController browser window as a sheet for a window.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.5.

  • Allocator work Bluetooth Service Browser window controller.

    Declaration

    Swift

    init!(_ inOptions: IOBluetoothServiceBrowserControllerOptions) -> IOBluetoothServiceBrowserController

    Objective-C

    + (IOBluetoothServiceBrowserController *)serviceBrowserController:(IOBluetoothServiceBrowserControllerOptions)inOptions

    Parameters

    inOptions

    Bit field for options to set in the newly allocated controller. Currently no options are available.

    Return Value

    a new instance of the IOBluetoothServiceBrowserController Controller, nil if unsuccessful.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.

  • Method call to convert an IOBluetoothServiceBrowserControllerRef into an IOBluetoothServiceBrowserController *.

    Declaration

    Swift

    class func withServiceBrowserControllerRef(_ serviceBrowserControllerRef: IOBluetoothServiceBrowserController!) -> IOBluetoothServiceBrowserController!

    Objective-C

    + (IOBluetoothServiceBrowserController *)withServiceBrowserControllerRef:(IOBluetoothServiceBrowserControllerRef)serviceBrowserControllerRef

    Parameters

    serviceBrowserControllerRef

    IOBluetoothServiceBrowserControllerRef for which an IOBluetoothServiceBrowserController * is desired.

    Return Value

    Returns the IOBluetoothServiceBrowserController * for the given IOBluetoothServiceBrowserControllerRef.

    Import Statement

    Objective-C

    @import IOBluetoothUI;

    Swift

    import IOBluetoothUI

    Availability

    Available in OS X v10.2 and later.