Printing Boolean values with NSLog function

In this section we will show you how you can print the values of Boolean using NSLog.

 
 

Share on Google+Share on Google+

Printing Boolean values with NSLog function

Ads

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


Advertisements

Ads

Posted on: July 29, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles