Home Tutorial Iphone Examples Nslog Printing Boolean values with NSLog function

 
 

Printing Boolean values with NSLog function
Posted on: July 29, 2009 at 12:00 AM
In this section we will show you how you can print the values of Boolean using NSLog.

The default value of BOOL variable is NO. You can use the following code to find the value of BOOL variable. 

//
//  PrintBoolean.h
//  DataTypes
// 

#import <Foundation/Foundation.h>

@interface PrintBoolean : NSObject {

    BOOL mBool;

}

-(void) print;

@end

and the code of the implementation class will be:

//
//  PrintBoolean.m
//  DataTypes
// 

#import "PrintBoolean.h"

@implementation PrintBoolean

-(void) print{

NSLog(@"The value of the bool is %@\n", (mBool ? @"YES" : @"NO"));

}

@end


Related Tags for Printing Boolean values with NSLog function:


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.