NSString Category for Hyperlink extraction
Objective-C
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
NSStringHyperlink.xcodeproj
NSStringHyperlink
NSStringHyperlinkTests
NSString+Hyperlink.h
NSString+Hyperlink.m
NSStringExtractedComponent.h
NSStringExtractedComponent.m
README

README

=======================================================================
 INSTALL
=======================================================================

Copy files 

- NSString+Hyperlink.h
- NSString+Hyperlink.m
- NSStringExtractedComponent.h
- NSStringExtractedComponent.m

=======================================================================
 USAGE
=======================================================================

- hyperlink

    #import "NSString+Hyperlink.h"

    NSString *str = @"foobar http://example.org/1 foobar http://example.org/2";
    NSArray *urls = [str hyperlinks];
    for (NSString *urlString in urls) {
        NSLog(@"URL: %@", urlString);
    }

- componentsSplittedByHyperlink

    NSArray *components = [str componentsSplittedByHyperlink];
    for (NSStringExtractedComponent *comp in components) {                     
        switch (comp.type) {            
            case NSStringExtractedComponentTypeNormal:                         
                NSLog(@"TEXT: %@", comp.string);
                break;
            case NSStringExtractedComponentTypeHyperlink:                      
                NSLog(@"URL: %@", comp.string);                                
                break;                                                             
        }
    }

- componentsSplittedByHyperlink:withTrimming

    // you can get non-trimmed components
    NSArray *components = [str componentsSplittedByHyperlinkWithTrimming:NO];
    // same as componentsSplittedByHyperlink for rest

=======================================================================
 License
=======================================================================

MIT License

Copyright (c) 2012 Lyo Kato <lyo.kato at gmail dot com>
All rights reserved.