Created
March 4, 2014 02:14
-
-
Save keicoder/9339006 to your computer and use it in GitHub Desktop.
objective-c : automatically extract first line of string, based on the first few words
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
// automatically extract first line of string, based on the first few words | |
// for example, can using this for title of note | |
//.h | |
// | |
@property NSString* contents; | |
@property (readonly) NSString* title; | |
//.m | |
- (NSString *)title { | |
// split into lines | |
NSArray* lines = [self.contents componentsSeparatedByCharactersInSet: [NSCharacterSet newlineCharacterSet]]; | |
// return the first | |
return lines[0]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment