Question

    NSString *string1 = @"string one";
    NSString *string2 = @"string two";
    NSString *string3 = [string1 stringByAppendingString:string2 ];

For the current version of Xcode, with the above snippet does each string1, string2, string3 get defined at compile time or run time?

Was it helpful?

Solution 2

The code to allocate space for the variables themselves (if the compiler actually deems it necessary to do so) will be generated at compile-time and executed at runtime. The two constant strings will be created at compile-time as well, similar to constant C strings. The message send will not be executed until runtime.

OTHER TIPS

You define the strings in memory at compile time(for string1 and string2).

string1, string2 and string3 will point to that that memory at runtime when their respective instructions are being executed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top