Latest 0.0.1
Homepage https://github.com/keepingitneil/NDDLazyString
License MIT
Platforms ios 7.0, requires ARC
Authors

Allows for asynchronous, arbitrary order, string manipulation. This library is super new and not even close to complete :) The motivation for NDDLazyString is to be able to modify atributed strings while conserving the original ranges of the text you’re modifying.

CocoaPods

pod 'NDDLazyString', '~> 0.0'

Motivating Example

Say you would like to replace all instances of ‘:)’ with an image of a smiley.

    NSString *string = @":) hello world :) Happy Friday!";

    NSArray *ranges = nil; //get all of the ranges of :) using your preferred method. REGEX is nice :)
    NDDLazyString *lazyString = [[NDDLazyString alloc] initWithString:string];

    [lazyString beginUpdates];

    for(NSValue *value in ranges) {
        NSRange range = [value rangeValue];
        [lazyString replaceCharactersInRange:range fromLazyChangeBlock:^NSAttributedString *{
            NSAttributedString *replaceString = nil;//some attributedString to replace :) with
            return replaceString;
        } completionBlock:^(NDDLazyString *lazySring, NSError *error) {
            //do something with lazyString.attributedString
        }];
    }

    [lazyString endUpdates];

Limitations

Right now this only works asynchrounously. The motivating example would probably be better done synchrounously wih an local asset.

Future Work

Would like to parse HTML for simple text manipulations and img tags.

How to contribute

Hit me up! No plans right now to turn this into a giant project. But if you want to contribute because your project needs something like this, lmk and we can get a workflow going.

Latest podspec

{
    "name": "NDDLazyString",
    "version": "0.0.1",
    "summary": "Allows for asynchronous, arbitrary order, string manipulation.",
    "description": "Allows for asynchronous, arbitrary order, attributed string manipulation.",
    "homepage": "https://github.com/keepingitneil/NDDLazyString",
    "source": {
        "git": "https://github.com/keepingitneil/NDDLazyString.git",
        "tag": "0.0.1"
    },
    "license": "MIT",
    "authors": {
        "keepingitneil": "[email protected]"
    },
    "source_files": [
        "NDDLazyString/Library",
        "NDDLazyString/Library/**/*.{h,m}"
    ],
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This