Swift compiler segmentation fault when building

后端 未结 30 2703
南旧
南旧 2020-11-29 03:59

Adding a (convenient) computed height property to UIView in my UIViewExtension.swift file is causing the Swift compiler to segfault...

30条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 04:46

    I had the same problem in an extension. My extension had two convenience initializers:

    convenience init(context: NSManagedObjectContext) {
        let entityDescription = NSEntityDescription.entityForName("PropertyEntity", inManagedObjectContext: context)!
        self.init(entity: entityDescription, insertIntoManagedObjectContext: context)
    }
    
    convenience init(dictionary: NSDictionary, context: NSManagedObjectContext) {
        self.init(context: context)
        property1 = (dictionary["key"] as? String) ?? ""
        // More properties...
    }
    

    To get rid of the error I added an instance method map(dictionary: NSDictionary) and the segmentation fault error disappeared.

    convenience init(dictionary: NSDictionary, context: NSManagedObjectContext) {
        self.init(context: context)
        map(dictionary)
    }
    

提交回复
热议问题