Home Tutorial Iphone Examples Nslog NSLog float example code

 
 

Share on Google+Share on Google+
NSLog float example code
Posted on: July 29, 2009 at 12:00 AM
Advertisement
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.

 

Advertisement

Related Tags for NSLog float example code:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 29, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com