Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/williamFalcon/SwiftTryCatch
Adds try-catch support for Swift
https://github.com/williamFalcon/SwiftTryCatch
Last synced: 3 months ago
JSON representation
Adds try-catch support for Swift
- Host: GitHub
- URL: https://github.com/williamFalcon/SwiftTryCatch
- Owner: williamFalcon
- License: mit
- Created: 2014-10-10T18:17:14.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T13:39:27.000Z (almost 2 years ago)
- Last Synced: 2024-04-09T11:59:44.956Z (7 months ago)
- Language: Objective-C
- Homepage:
- Size: 12.7 KB
- Stars: 140
- Watchers: 9
- Forks: 60
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
SwiftTryCatch
=============Adds try/catch support for Swift.
Simple wrapper built around Objective-C `@try`/`@catch`/`@finally`.
##Usage
### Install via Cocoapods
pod 'SwiftTryCatch'
### Import
If using Frameworks for pods (use_frameworks! flag in Podfile):
import SwiftTryCatch
or import into Obj-C bridging header:
#import "SwiftTryCatch.h"
### Use
SwiftTryCatch.try({
// try something
}, catch: { (error) in
print("\(error.description)")
}, finally: {
// close resources
})
## Notes
It was pointed out that without -fobjc-arc-exceptions flag this will lead to memory leakshttp://clang.llvm.org/docs/AutomaticReferenceCounting.html#exceptions
Therefore, ARC-generated code leaks by default on exceptions, which is just fine if the process is going to be immediately terminated anyway. Programs which do care about recovering from exceptions should enable the option.