What is the maximum sized string that can be held in a NSString object?
Does this change dynamically?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would assume the hard limit for NSString would be NSUIntegerMax characters, since NSString’s index and size-related methods return an NSUInteger. Since all devices currently capable of running iOS are 32 bit, this means NSUIntegerMax is 2^32 – 1 and NSString can hold a little over 4.2 billion characters.
As others have pointed out, though, the practical limit is much smaller – on an iOS device especially, you’ll run out of memory long before you hit any hard limit in NSString.