Reputation: 1289
hii every one
is there a way to get the character count in a string in obj c?
like how does the SMS app determine how big of a bubble the text view sends and receives? thanks a lot
Upvotes: 0
Views: 2168
Reputation: 3945
If it is a NSString
then
[string length];
Not sure if you are talking about multi-bytes characters
Upvotes: 1
Reputation: 39988
If it is NSString
then use str.length
If it is c string then use strlen(cString)
Upvotes: 1
Reputation: 26400
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]);
Upvotes: 0
Reputation: 2157
You can use something like this:
NSString *str = @"Hello World!";
NSUInteger len = str.length;
Upvotes: 2