Skip to content

shinyfrog/TextBundle

Repository files navigation

TextBundle

TextBundleWrapper is a fast and simple Library for reading/writing TextBundle files.

Table of Contents

Installation

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.

Install from sources

Just download and drag the TextBundleWrapper.{h,m} files in your Xcode project

Carthage

To install with Carthage, add the following to your Cartfile: github "shinyfrog/TextBundle"

Framework

Reference the TextBundle.xcodeproj in your project and drag the TextBundle.framework inside the Embedded Binaries in the General tab of the target setting.

Usage

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.

Reading the TextBundle Text

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;

Reading the TextBundle Assets

// 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];
}];

Reading the TextBundle Meta Data

TextBundleWrapper conforms to the TextBundle Specification, please use the specs as reference for properties and their values.

NSDictionary *metadata = tb.metadata;

Author

Matteo Rattotti

License

TextBundleWrapper is available under the MIT license. See the LICENSE file for details.

Contacts

If you want to ask a technical question, feel free to raise an issue or write to hello@shinyfrog.net.

About

Framework for reading/writing TextBundle files

Resources

License

Stars

Watchers

Forks

Packages

No packages published