Hi there,
I wanted to call the Bluetooth initWithDictionary and its option CBCentralManagerOptionShowPowerAlertKey;
There is little information out there howto create the options for this call in the right way.
CBCentralManager = interface(NSObject)
['{587D1855-5B53-43DA-91AF-AF9D93FFDB9F}']
...
function initWithDelegate(delegate: id; queue: dispatch_queue_t; options: NSDictionary): id; cdecl; overload;
In XCode that looks quite straightforward, but what about Fmx ?
let opts = [CBCentralManagerOptionShowPowerAlertKey: false]
let manager = CBCentralManager(delegate: self,
queue: nil,
options: opts)
Info's like this doesn't help much
http://codeverge.com/embarcadero.delphi.firemonkey/help-rewrite-objective-c-proced/1046099
Using NSUserDefaults to access the info list properties seems not to work, returning nil.
But is NSUserDefaults the right place to look for those keys ?
var
LDefaults: NSUserDefaults;
LDict: NSDictionary;
begin
LDefaults := TNSUserDefaults.Wrap(TNSUserDefaults.OCClass.standardUserDefaults);
LDict := LDefaults.dictionaryForKey( CBCentralManagerOptionShowPowerAlertKey ); // ! This (LDict) is nil
if Assigned(lDict) then
FCentralManager := TCBCentralManager.Wrap(
TCBCentralManager.Alloc.initWithDelegate(
GetObjectID,
0,
LDict
))
I used this function to get the key constant
function CBCentralManagerOptionShowPowerAlertKey : NSString;
begin
Result := CocoaNSStringConst(libCoreBluetooth, 'CBCentralManagerOptionShowPowerAlertKey');
end;
Other ways to construct this NSDictionary look to ugly to be true:
LDict := TNSDictionary.Wrap(
TNSDictionary.OCClass.dictionaryWithObjectsAndKeys(
<<This is Pointer to object a nil-terminated list>>));
Maybe somebody can help with some useful hints, to find the right way to access such system options ?