The first line creates a new, empty string. Length 0. It's just @"". You can accomplish the same thing by NSString *myString = @"";
Class vs Instances is the last question you have. Class is the "I want to make what this method gives me". If you are using [NSString string]
, then essentially you are doing [[NSString alloc] init]
. So, the instance gives you access to methods and variables that are for your Class instance (aka myString), so [myString length]
. You can't do [NSString length]
.
Class methods are the interface to getting an instance (or getting the class type), and instance methods are for the in memory instance of that class that you are actually using.
Sorry for the convoluted answer.