I'm a little confused when coding an Objective-C project. The ARC is on. Here is a sample code:
NSString *foo = [[NSString alloc] initWithUTF8String:"This is a C string."];
// Use foo here...
foo = @"This is an ObjC string."
Here are my questions:
Do I need to explicitly terminate C string with '\0' in
initWithUTF8String:method, or it is okay to omit NULL terminator?Is there any memory leakage when I reuse
fooas a pointer and assign new Objective-C string to it? Why?If I change
NSStringto other class, likeNSObjector my own class, is there any difference for question 2? (Initialize an object and then reassign other value directly to it.)
Thank you!