Reputation: 4518
I have a certain confusion on how to return values in Objective C with NSString return type but having variables inside it.
Is this okey?
- (NSString *)returnInfo{
return @"Userinfo:\nusername: %@\npassword: %@", self.username, self.password;
}
Your answers are highly appreciated... Thanks...
Upvotes: 0
Views: 3398
Reputation: 726519
It should probably be
- (NSString *)returnInfo{
return [NSString stringWithFormat:@"Userinfo:\nusername: %@\npassword: %@", self.username, self.password];
}
Your code would probably compile too, but it would return password
, because of the way the comma operator works. This is almost certainly not what you had in mind, though.
Upvotes: 7