Hi guys,
Its been at least a year since I touched code and I'm a bit rusty, can someone answer two questions for me? (Also this is just practice I know this won't compile because of the same variable names).
I have two lines of code here that simply assign a value to the NSString variable:
I typed the first one by accident and didn't expect it to compile but it did. How come I didn't have to initialize this string?
Also regarding the second one, for simply assigning a value to a string I thought there was a different way instead of using [NSString alloc] initWithFormat] but nothing in the documentation jumped out at me as something I remembered doing.
Sorry if these sound silly its been awhile
Its been at least a year since I touched code and I'm a bit rusty, can someone answer two questions for me? (Also this is just practice I know this won't compile because of the same variable names).
I have two lines of code here that simply assign a value to the NSString variable:
Code:
NSString *adam = @"Adam"; //Is this legal?
NSString *adam = [[NSString alloc] initWithFormat: @"Adam"]; //Is this the correct way?
I typed the first one by accident and didn't expect it to compile but it did. How come I didn't have to initialize this string?
Also regarding the second one, for simply assigning a value to a string I thought there was a different way instead of using [NSString alloc] initWithFormat] but nothing in the documentation jumped out at me as something I remembered doing.
Sorry if these sound silly its been awhile