> On 11 Aug 2014, at 05:53, Gerriet M. Denkmann <gerr...@mdenkmann.de> wrote:
> 
> 
> On 11 Aug 2014, at 15:43, Bavarious <bavari...@icloud.com> wrote:
> 
>> On 11 Aug 2014, at 05:35, Gerriet M. Denkmann <gerr...@mdenkmann.de> 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?
>> 
>> 
>> 
>> let cfname = name as CFString
>> 
>> should work.
> 
> You are right: it should work.
> But
>       let cref = name as CFString
> again created the error: 'NSString' is not a subtype of 'CFString'
> 
> Xcode 6 beta 5

What is the type of xpcServiceName? If it’s a Swift string, you need to go 
through NSString first. If it’s an NSString, just as CFString should work.

I get no compiler errors with this code:

import Foundation

let s = "string"
let nss = s as NSString
let cfs1 = s as NSString as CFString
let cfs2 = nss as CFString


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to