TextBundleWrapper is a fast and simple Library for reading/writing TextBundle files.
TextBundleWrapper is a single class with no dependencies, you can install it from source code, using Carthage or embedding the TextBundle.framework in your project.
Just download and drag the TextBundleWrapper.{h,m} files in your Xcode project
To install with Carthage, add the following to your Cartfile:
github "shinyfrog/TextBundle"
Reference the TextBundle.xcodeproj in your project and drag the TextBundle.framework inside the Embedded Binaries in the General tab of the target setting.
If you're using TextBundle as a framework, you can @import TextBundle if you’re using swift or #import <TextBundle/TextBundle.h> for Obj-C.
NSError *e = nil;
TextBundleWrapper *tb = [[TextBundleWrapper new] initWithContentsOfURL:fileURL
options:NSFileWrapperReadingImmediate
error:&e];
// Reading the plain text content
NSString *text = tb.text;
// The UTI of the text (Markdown, HTML, etc...)
NSString *type = tb.type;// Iterating the asset files
[tb.assetsFileWrapper.fileWrappers enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSFileWrapper *fw, BOOL *stop)
{
// File name
NSString *filename = fw.filename;
// Writing the file somewhere
[fw writeToURL:URL options:0 originalContentsURL:nil error:nil];
}];TextBundleWrapper conforms to the TextBundle Specification, please use the specs as
reference for properties and their values.
NSDictionary *metadata = tb.metadata;TextBundleWrapper is available under the MIT license. See the LICENSE file for details.
If you want to ask a technical question, feel free to raise an issue or write to [email protected].