ishaq Posted October 11, 2008 Share Posted October 11, 2008 okay, this might be a silly question, but I can't find a selector that capitalizes only the first letter of a string, is there one? or do I need to write my own? -- MI Link to comment Share on other sites More sharing options...
justvisiting Posted October 12, 2008 Share Posted October 12, 2008 http://developer.apple.com/documentation/C...e/NSString.html capitalizedString Returns a capitalized representation of the receiver. - (NSString *)capitalizedString Return Value A string with the first character from each word in the receiver changed to its corresponding uppercase value, and all remaining characters set to their corresponding lowercase values. Discussion A “word” here is any sequence of characters delimited by spaces, tabs, or line terminators (listed under getLineStart:end:contentsEnd:forRange:). Other common word delimiters such as hyphens and other punctuation aren’t considered, so this method may not generally produce the desired results for multiword strings. Case transformations aren’t guaranteed to be symmetrical or to produce strings of the same lengths as the originals. See lowercaseString for an example. Availability Available in Mac OS X v10.0 and later. See Also – lowercaseString – uppercaseString Declared In NSString.h Link to comment Share on other sites More sharing options...
ishaq Posted October 12, 2008 Author Share Posted October 12, 2008 capitalizeString capitalizes first letter of every word, I just need the first letter of the first word. Link to comment Share on other sites More sharing options...
stroke Posted October 12, 2008 Share Posted October 12, 2008 NSString *myString = @"this is a string."; NSString *flcString = [myString stringByReplacingCharactersInRange:NSMakeRange(0,1) withString:[[myString substringToIndex:1] capitalizedString]]; Link to comment Share on other sites More sharing options...
Recommended Posts