LoginSignup
12
8

More than 5 years have passed since last update.

Swift3+iOS8ではCIContextのイニシャライザでクラッシュするバグがあるもよう

Posted at

CIContext()CIContext(options:)などが実行時にクラッシュします。

エラー
-[CIContext initWithOptions:]: unrecognized selector sent to instance 0xhogehoge

すでにバグレポートされているようです。
https://openradar.appspot.com/28200846

回避方法

stackoverflow([CIContext initWithOptions:]: unrecognized selector sent to instance 0x170400960 in xcode8)に書かれている方法だとうまく動かなかった(やり方がまずい?)ので、こんないい加減なクラスを用意して、ブリッジさせ、

ObjcUtility.h
#import <UIKit/UIKit.h>

@interface ObjcUtility : NSObject 

+ (CIContext *)cicontextWithOptions:(NSDictionary<NSString *, id> *)options;

@end

ObjcUtility.m
#import "ObjcUtility.h"

@implementation ObjcUtility

+ (CIContext *)cicontextWithOptions:(NSDictionary<NSString *, id> *)options {
    return [CIContext contextWithOptions:options];
}

@end

Swift側でObjcUtility.cicontext(options:)を呼び出すことでイニシャライズの代理としてみました。

急いで書いたので間違いがあったらすみません。

12
8
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
8