The following code example of NSLog function prints the value of float variable. You can use the technique discussed here in your iPhone application to test and debug the code.
Here is the code example of NSLog function that prints the value of float.
//
// PrintFloat.h
// DataTypes
//
//
#import <Foundation/Foundation.h>
@interface PrintFloat : NSObject
{
float _float;
}
-(void) print;
-(void) set_float: (float) n;
@end
The class implementation code is as follows:
//
// PrintFloat.m
// DataTypes
//
#import "PrintFloat.h"
@implementation PrintFloat
-(void) set_float: (float) n
{
_float = n;
}
-(void) print {
NSLog(@"float value is: %f", _float);
}
@end
The %f is used here in the above example.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.