www.wallcity.org | Zack Smith

Converting a Check Box value to Boolean

Here is simple little objective c method that will take a IBOutlet and query its value to return a boolean. I typically need to do this to run a logical test on the interface value. My guess is properties & bindings are the better way to do this but as BOOL is not an object I am not quite sure how that would be done.

-(BOOL)evaluateCheckBox:(NSButton *)evalButton
{
	// Gather data from interface
	if ( [evalButton state] == NSOnState ){
		return YES;
	}
	if ( [evalButton state] == NSOffState ){
		return NO;
	}
}

Write a Comment