Latest0.1.0
Homepagehttps://github.com/skyweb07/Samba
LicenseMIT
Platformsios 7.0, requires ARC
FrameworksUIKit, Foundation
Authors

Version
License
Platform

Description

Samba is a mini port for Swift 2.0 availability checking. If you’ve been into the iOS development I’m sure that you know the tedious work to check if a particular API is available on the device your application is running on. Before Swift 2 availability check you probably had something like this

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
    // use registerUserNotificationSettings
#else
    // use registerForRemoteNotificationTypes
#endif

or

if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
    // use registerUserNotificationSettings
} else {
    // use registerForRemoteNotificationTypes
}

or some macros for checking if the OS is at least a version and then do the dirty work. Well with Swift 2.0 this is as easy as

if #available(iOS 8.0, *) {
    // use registerUserNotificationSettings
} else {
    // use registerForRemoteNotificationTypes
}

Simple and elegant, that’s what we want. In Objective-C we don’t have that nice feature so Samba is trying to fix that hole with a simple function that do the system version check for you.

SKOperatingSystemVersion version = (SKOperatingSystemVersion) {8, 0, 0};

available(version, ^{
    // use registerUserNotificationSettings
}, ^{
    // use registerForRemoteNotificationTypes
});

Simple ha?, in the end Samba uses a simple compare againts [UIDevice currentDevice].systemVersion but it’s simpler than having all your code full of if’s checks.

Swift 2.0 availability check is more powerfull than this but you get the idea behind Samba, if you want to keep reading about this Swift new feature you can check this docs:

Requirements

iOS 7.0 and later

Installation

Samba is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "Samba"

Author

Oscar Antonio Duran Grillo, [email protected]

License

Samba is available under the MIT license. See the LICENSE file for more info.

Happy coding 🍻

Latest podspec

{
    "name": "Samba",
    "version": "0.1.0",
    "summary": "Swift availability check port for Objective-C",
    "description": "Samba is a mini port for Swift 2.0 availability checking.",
    "homepage": "https://github.com/skyweb07/Samba",
    "license": "MIT",
    "authors": {
        "Oscar Antonio Duran Grillo": "[email protected]"
    },
    "source": {
        "git": "https://github.com/skyweb07/Samba.git",
        "tag": "0.1.0"
    },
    "social_media_url": "https://twitter.com/skyweb07",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "frameworks": [
        "UIKit",
        "Foundation"
    ]
}

Pin It on Pinterest

Share This