Debug casting class


id DebugCastCpp(id sourceClass, Class cl)
{
	if (sourceClass != nil)
	{
		if (![sourceClass isKindOfClass: cl])
		{
            NSLog(@"%@", [NSString stringWithFormat: @"The cast is invalid (%@ to %@)", [sourceClass class], cl]);
			@throw [NSException exceptionWithName:@"CastException" reason: [NSString stringWithFormat: @"The cast is invalid (%@ to %@)", [sourceClass class], cl] userInfo:nil];
		}
	}
	
	return sourceClass;
}



Advertisements