Skip to content

Helper method to catch unexpected ObjC exceptions in Swift

Notifications You must be signed in to change notification settings

nesterenkodm/ObjC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ObjC

Helper method to catch unexpected ObjC exceptions in Swift.

Usage

do {
    try ObjC.catchException {
        let collectionView = UICollectionView()
        collectionView.insertItems(at: [IndexPath(row: 10, section: 10)])
    }
} catch {
    print(error.localizedDescription) // prints "UICollectionView must be initialized with a non-nil layout parameter"
    
    if case ObjC.Error.exception(let exception) = error {
        print(exception.callStackSymbols) // prints stack trace
    }
    
    // recover from NSInternalInconsistencyException
}

About

Helper method to catch unexpected ObjC exceptions in Swift

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published