小编loo*_*sta的帖子

如何将swift String转换为CFString

如何在swift中从本机swift String或NSString创建CFString

    let path:String = NSBundle.mainBundle().pathForResource(name.stringByDeletingPathExtension, ofType:"pdf")
    let string:CFString = ??? path
    let url:CFURLRef = CFURLCreateWithFileSystemPath(allocator:kCFAllocatorDefault, filePath:string, pathStyle:CFURLPathStyle.CFURLPOSIXPathStyle, isDirectory:false)
Run Code Online (Sandbox Code Playgroud)

cfstring swift

33
推荐指数
4
解决办法
2万
查看次数

用swift导致CGBitmapContextCreate错误

我试图在swift中创建一个CGContext.它编译但在运行时抛出错误.

let colorSpace:CGColorSpace = CGColorSpaceCreateDeviceRGB()
let context:CGContext = CGBitmapContextCreate(nil, 20, 20, 8, 0, colorSpace, CGBitmapInfo.AlphaInfoMask)
CGColorSpaceRelease(colorSpace);

....
Run Code Online (Sandbox Code Playgroud)

错误是:

Error: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; unrecognized; 96 bytes/row.
fatal error: Can't unwrap Optional.None
Run Code Online (Sandbox Code Playgroud)

cgcontext swift

29
推荐指数
4
解决办法
2万
查看次数

如何在swift中使用NSURLConnection completionHandler

有人知道处理程序(块)如何在swift中工作吗?我正在尝试运行此代码,但我找不到完成正确语法的任何文档.

let url:NSURL = NSURL(string:"some url")
let request:NSURLRequest = NSURLRequest(URL:url)
let queue:NSOperationQueue = NSOperationQueue()

NSURLConnection.sendAsynchronousRequest(request:request, queue:queue, completionHandler handler:((NSURLResponse!, NSData!, NSError!) -> Void)!)
Run Code Online (Sandbox Code Playgroud)

block nsurlconnection swift

17
推荐指数
1
解决办法
2万
查看次数

标签 统计

swift ×3

block ×1

cfstring ×1

cgcontext ×1

nsurlconnection ×1