Latest 0.1.0
Homepage https://github.com/andrewschreiber/TextFlipKit
License MIT
Platforms ios , requires ARC
Authors

alt tag

language
Version
MIT License
Platform

An NSString and NSAttributedString category that makes it easy to flip and reverse text. Flipped text can be sent in text messages, emails, etc.

Usage

#import TextFlipKit.h;

- (void)foo
{
    NSString *example = @"Example String";
    NSLog(@"'%@'", example.tfk_upsideDownAndReversed);
    //Prints 'ƃuᴉɹʇS ǝldɯɐxƎ'. Looks normal upside down

    NSLog(@"'%@'",testString.tfk_upsideDown);
    //Prints 'Ǝxɐɯdlǝ Sʇɹᴉuƃ'

    NSLog(@"'%@'",testString.tfk_reversed);
    //Prints 'gnirtS elpmaxE'
}

Given a string of 100,000 characters, it takes ~0.1 second to flip upside down, ~0.3 seconds to reverse, and ~0.4 seconds to flip and reverse on an iPhone 6. Each function can be called as a block, in case you want to flip long strings off the main thread.

- (void)bar
{
    NSString *completedWorksOfShakespeare = [NSString stringWithContentsOfFile:completedWorks encoding:NSASCIIStringEncoding error:nil];
    [completedWorksOfShakespeare tfk_upsideDownAndReverseWithCompletionBlock:^(NSString *upsideDownAndReversed)
    {
        //Save to disk
    }
}

Attributed Strings

Flipped attributed strings maintain the attributes of each character.

alt tag

Requirements

  • ARC
  • iOS 4.0 or later

Installation

You can either add the TextFlipKit.h and TextFlipKit.m files directly to your project, or install via CocoaPods.

pod 'TextFlipKit', '~> 0.1.0'

Special thanks

@somegeekintn on StackOverflow

http://stackoverflow.com/questions/4158646/most-efficient-way-to-iterate-over-all-the-chars-in-an-nsstring

Latest podspec

{
    "name": "TextFlipKit",
    "version": "0.1.0",
    "license": "MIT",
    "summary": "A NSString & NSAttributedString category for flipping and reversing text.",
    "homepage": "https://github.com/andrewschreiber/TextFlipKit",
    "authors": {
        "Andrew Schreiber": "[email protected]"
    },
    "source": {
        "git": "https://github.com/andrewschreiber/TextFlipKit.git",
        "tag": "0.1.0"
    },
    "description": "Can reverse text and/or convert each character into its upside down unicode equivalent",
    "platforms": {
        "ios": null
    },
    "source_files": [
        "TextFlipKit.h",
        "TextFlipKit.m"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This