hii every one
is there a way to get the character count in a string in ob开发者_StackOverflow中文版j c?
like how does the SMS app determine how big of a bubble the text view sends and receives? thanks a lot
You can use something like this:
NSString *str = @"Hello World!";
NSUInteger len = str.length;
If it is NSString
then use str.length
If it is c string then use strlen(cString)
If it is a NSString
then
[string length];
Not sure if you are talking about multi-bytes characters
length
Returns the number of Unicode characters in the receiver.
- (NSUInteger)length
Return Value
The number of Unicode characters in the receiver. Discussion
The number returned includes the individual characters of composed character sequences, so you cannot use this method to determine if a string will be visible when printed or how long it will appear.
NSLog(@"Length of your string is %d",[yourString length]);
精彩评论