Re: Converting to Swift
Re: Converting to Swift
- Subject: Re: Converting to Swift
- From: Bavarious <email@hidden>
- Date: Mon, 11 Aug 2014 05:43:50 -0300
On 11 Aug 2014, at 05:35, Gerriet M. Denkmann <email@hidden> wrote:
>
> I am trying to convert:
> NSString * helperName = @"de.mdenkmann.Xpc-Exchange”;
> CFDictionaryRef diref = SMJobCopyDictionary( kSMDomainSystemLaunchd, (__bridge CFStringRef)helperName );
> NSDictionary *jobDict = (NSDictionary *)CFBridgingRelease(diref);
> if ( jobDict == nil ) need to start the helper
>
> to Swift:
> let name = xpcServiceName!
> let diref = SMJobCopyDictionary( kSMDomainSystemLaunchd, name )
> but get an error for name: "'NSString' is not a subtype of 'CFString'"
>
> let cref = CFString(name) → error: 'CFString' cannot be constructed because it has no accessible initializers
>
> How to get a CFString?
name as CFString
should work as an expression. If you want a variable, then
let cfname: CFString = name
or
let cfname = name as CFString
should work.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden