Reputation: 1
I have a series of textfields the user will enter in values (one is a string the others numeric). When I try to get the text from:
NSString *strCal = txtfieldCal.text;
NSLog(@"cal entered: %a", strCal);
Returns:
calories Entered: -0x1.fd55804e2e26p+0
I have the outlets referenced correctly in IB.
I don't know if this matters or not, but I can populate the textfields on viewload, but I cannot get the value afterwards.
Upvotes: 0
Views: 345
Reputation: 7200
You need to use %@ to put strings into NSLog. %a likely shows something else, - it looks like a number from the man page in terminal (type man printf)
NSLog(@"cal entered: %@", strCal);
Just thought that you may well WANT a number. Well you get a string -its a text field. To get a number, you call something like
NSLog(@"cal entered: %f", [strCal doubleValue]);
Upvotes: 3