Home Tutorial Iphone Examples Nslog NSLog float example code

 
 

NSLog float example code
Posted on: July 29, 2009 at 12:00 AM
In this section we will see the correct example of NSLog function that prints the float value.

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.

 

Related Tags for NSLog float example code:


Ask Questions?

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.