The standard Xcode 5 OpenGLES template example creates an application that includes the following as part of the shader loading code:
const GLchar *source;
source = (GLchar *)[[NSString stringWithContentsOfFile:file encoding:NSUTF8StringEncoding error:nil] UTF8String]; // load file
...
glShaderSource(*shader, 1, &source, NULL);
After wading through Clang LLVM ARC, I would have expected the NSString object created from the contents of the file to "get released at the end of the full-expression containing it".
However, then UTF8String method is declared in NSString.h
as:
- (__strong const char *)UTF8String;
Does this mean that ARC is smart enough to figure out that the NSString object should be retained until source
goes out of scope? Or am I way off track?