Skip to content

seanparsons/SwiftTryCatch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftTryCatch

Adds try/catch support for Swift.

Simple wrapper built around Objective-C @try/@catch/@finally.

Note: This repository was originally forked from https://github.com/williamFalcon/SwiftTryCatch and updated to work with Swift 2.0, since the original API conflicted with new try/catch keywords introduced by new Swift version.

##Usage

Install via Swift Package Manager

To use this specific repository version of SwiftTryCatch add it to your Package.swift manifest.

import PackageDescription

let package = Package(
    name: "YourModule",
    dependencies: [
        .Package(url: "https://github.com/seanparsons/SwiftTryCatch.git", majorVersion: 1, minor: 1),
    ]
)

Install via CocoaPods

To use this specific repository version of SwiftTryCatch use the following pod definition:

pod 'SwiftTryCatch', :git => 'https://github.com/ravero/SwiftTryCatch.git'

This will use the podspec from this forked repository with the API signature changes.

Create bridging header

  • When prompted with "Would you like to configure an Obj-C bridging header?", press "Yes".
  • Go to bridging header and add:
#import "SwiftTryCatch.h"

Use

SwiftTryCatch.tryBlock({
        // try something
    }, catchBlock: { (error) in
        println("\(error.description)")
    }, finallyBlock: {
        // close resources
    })

About

Adds try-catch support for Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 79.3%
  • Ruby 12.5%
  • Swift 8.2%