Why do two NSStrings taken from user input end up with the same address?
I am curious to know how the OS or compiler manages the memory usage. Take this example of a login screen. If I enter the same strings for both user ID & password: say "anoop" both times, the following two strings have same addresses: NSString *userID = self.userNameField.stringValue; NSString *password = self.passwordField.stringValue; If I enter "anoop" & "Anoop" respectively, the address changes. How does the compiler know that the the password text is same as the user ID, so that instead of allocating a new memory space it uses the same reference? rob mayoff The answer in this case is that