#define kTestingURL @"192.168.42.179"
...
NSString *serverUrl = [[NSString alloc] initWithString:
[NSString stringWithFormat:@"http://%@", kTestingURL]];
NSLog(@"retain count: %d",[serverUrl retainCount]);
Why is the retain count 2 and not 1?
Yes, You will get retain Count 2, one for alloc and other for stringWithFormat. stringWithFormat is a factory class with autorelease but autorelease decreases retain count in the future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With