Created
July 3, 2013 21:15
-
-
Save scheinem/5922890 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Detects paragraphs in an UITextView and stores it in an NSMutableArray called "paragraphs" | |
* | |
* Author: Manfred Scheiner (@scheinem) | |
* Created on 03.07.2013 | |
*/ | |
- (void)textViewDidChange:(UITextView *)textView; { | |
NSMutableArray *paragraphs = [NSMutableArray array]; | |
for (NSString *component in [textView.text componentsSeparatedByString:@"\n"]) { | |
NSMutableString *mutableComponent = [component mutableCopy]; | |
while ([mutableComponent rangeOfString:@"\n"].location != NSNotFound) { | |
[mutableComponent deleteCharactersInRange:[mutableComponent rangeOfString:@"\n"]]; | |
} | |
if (mutableComponent.length > 0) { | |
[paragraphs addObject:mutableComponent]; | |
} | |
} | |
NSLog(@"Number of paragraphs: %u", paragraphs.count); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment