Hello, I have a class that can be initialized from a file. I would like to add a convenience init that uses a backup file if necessary. Writing a function for this is easy, but I can’t manage to turn this into an init function.
import Foundation class TestClass { init( fromFile file:NSURL ) throws { } convenience init( fromFile file:NSURL, fromBackupFile backupFile:NSURL ) throws { do { try self.init( fromFile:file ) } catch { do { try self.init( fromFile:backupFile ) } // error: 'self' used inside 'catch' block reachable from self.init call } } } func MakeTestClass( fromFile file:NSURL, fromBackupFile backupFile:NSURL ) throws -> TestClass { do { return try TestClass( fromFile:file ) } catch { do { return try TestClass( fromFile:backupFile ) } } } Any suggestions? _______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users