What is the length in bytes of a NSString?

ios, iphone, nsstring

Solution

NSString *test=@"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
NSUInteger bytes = [test lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"%i bytes", bytes);

Problem

How do I get the bytes length of `NSString`? if `myString` contains "hallo", `myString.length` will return 5, but how many actual bytes are taken?

Original source