Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save keicoder/9339006 to your computer and use it in GitHub Desktop.
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
// 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