Using NSArray, NSMutableArray, NSDictionary, NSMutableDictionary, NSMutableString safely by FFSafeKit.
- Safely access
NSArray
- Safely access
NSDictionary
- Safely access & perform changes to
NSMutableArray
- Safely access & perform changes to
NSMutableDictionary
- Safely access & perform changes to
NSMutableString
- iOS 8.0+ / macOS 10.13.6+
- Xcode 10.1 (10B61) +
To run the FFSafeKit
project, clone the Repo, and start FFSafeKit
in Xcode.
$ git clone https://github.com/JonyFang/FFSafeKit.git
$ cd FFSafeKit
$ cd Shell && sh install-bundle.sh && sh install-pods.sh && cd ..
$ open FFSafeKit.xcworkspace
There are three ways to use FFSafeKit in your project:
- Installation with
CocoaPods
- Installation with
Carthage
Manually
install
CocoaPods is a dependency manager, which automates and simplifies the process of using 3rd-party libraries like FFSafeKit in your projects. First, add the following line to your Podfile:
pod 'FFSafeKit'
If you want to use the latest features of FFSafeKit use normal external source dependencies.
pod 'FFSafeKit', :git => 'https://github.com/JonyFang/FFSafeKit.git'
This pulls from the master branch directly.
Second, install FFSafeKit into your project:
$ pod install
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate FFSafeKit into your Xcode project using Carthage, specify it in your Cartfile
:
github "JonyFang/FFSafeKit"
Run the following command to build the framework:
$ carthage update
Drag the built FFSafeKit.framework
binaries from Carthage/Build/iOS
into your application’s Xcode project.
On your application targets’ Build Phases
settings tab, click the + icon
and choose New Run Script Phase
. Create a Run Script
in which you specify your shell (ex: /bin/sh
), add the following contents to the script area below the shell:
/usr/local/bin/carthage copy-frameworks
Add the following paths to the frameworks you want to use under Input Files
.
$(SRCROOT)/Carthage/Build/iOS/FFSafeKit.framework
For an in depth guide, read on from Adding frameworks to an application.
Alternatively you can directly add the FFSafeKit folder
source files to your project.
- Download the latest code version or add the repository as a git submodule to your git-tracked project.
- Open your project in Xcode, then drag and drop
FFSafeKit folder
onto your project (use the"Product Navigator view"
). Make sure to selectCopy items
when asked if you extracted the code archive outside of your project. - Include FFSafeKit wherever you need it with
#import "FFSafeKit.h"
.
Import the library where you want to use it.
#import <FFSafeKit.h>
//Set `YES` to enable error logs for debug.
[FFSafeHelper ff_setupStatusToDebug:NO exceptionBlock:^(NSException * _Nonnull exception) {
NSLog(@"== exception ==\n%@", exception);
}];
FFSafeKit
is available under the MIT license. See the LICENSE file for more info.