开发者

Bad access on NSString length

开发者 https://www.devze.com 2023-02-25 07:32 出处:网络
with NSString *responseData = [request responseString]; I get a string like (10). Now I want to remove the brackets to get just the number. So I f开发者_运维知识库irst wanted to get the length of

with

NSString *responseData = [request responseString];

I get a string like (10).

Now I want to remove the brackets to get just the number. So I f开发者_运维知识库irst wanted to get the length of the string

NSLog(@"%@",[responseData length]);

But I get a Thread 1: Program received signal: "EXC_BAD:ACCESS"

Any ideas?


NSString::length returns an unsigned integer. So, try -

NSLog(@"%i",[responseData length]); // format specifier is %i and not %@
                                    // Even better if %u is used. 

NSLog format specifiers

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号