Is the code the same for Mac and iPhone because
Code:
[altitude setText:[NSString stringWithFormat:@"%.2f", alt]];
works fine in my iphone app.
That's not the code you first posted. If altitude is an object that responds to setText:, and alt is a double, then that code will work.
The problem is neither of those things is true for the code you first posted:
1. "label name" is not an object.
2. "float variable" is not a double variable.
Both are C strings.
So however you got that code to work in your iphone app, it seems that you don't really understand what it says or does.
If you don't know how to find any tutorials, you should probably start at the beginning.
At the top of this forum:
https://forums.macrumors.com/forums/73/
there's a Guide link with this name:
How do I get started programming on the Mac (or iPhone)?
You should also see some other useful links.
And you can search the MR site forums and look for keywords like
beginner. Or just scroll through recent postings in the forum. The question comes up every couple of days.