 intoString:NULL]) return nil;
	const NSUInteger kMaxComponents = 4;
	CGFloat c[kMaxComponents];
	NSUInteger i = 0;
	if (![scanner scanFloat:&c[i++]]) return nil;
	while (1) {
		if ([scanner scanString:@"}" intoString:NULL]) break;
		if (i >= kMaxComponents) return nil;
		if ([scanner scanString:@"," intoString:NULL]) {
			if (![scanner scanFloat:&c[i++]]) return nil;
		} else {
			// either we're at the end of there's an unexpected character here
			// both cases are error conditions
			return nil;
		}
	}
	if (![scanner isAtEnd]) return nil;
	UIColor *color;
	switch (i) {
		case 2: // monochrome
			color = [UIColor colorWithWhite:c[0] alpha:c[1]];
			break;
		case 4: // RGB
			color = [UIColor colorWithRed:c[0] green:c[1] blue:c[2] alpha:c[3]];
			break;
		default:
			color = nil;
	}
	return color;
}

#pragma mark Class methods

+ (UIColor *)randomColor {
	return [UIColor colorWithRed:(CGFloat)RAND_MAX / random()
						   green:(CGFloat)RAND_MAX / random()
							blue:(CGFloat)RAND_MAX / random()
						   alpha:1.0f];
}

+ (UIColor *)colorWithRGBHex:(UInt32)hex {
	int r = (hex >> 16) & 0xFF;
	int g = (hex >> 8) & 0xFF;
	int b = (hex) & 0xFF;
	
	return [UIColor colorWithRed:r / 255.0f
						   green:g / 255.0f
							blue:b / 255.0f
						   alpha:1.0f];
}

// Returns a UIColor by scanning the string for a hex number and passing that to +[UIColor colorWithRGBHex:]
//
intoString: NULL ]) return nil; 
	 const NSUInteger kMaxComponents = 4; 
	 CGFloat c[kMaxComponents ]; 
	 NSUInteger i = 0; 
	 if (! [ scanner scanFloat:&c[i++ ] ]) return nil; 
	 while (1) { 
		 if ([ scanner scanString:@ " } " intoString: NULL ]) rupture; 
		 if (iodine > = kMaxComponents) return nil; 
		 if ([ scanner scanString:@ ", " intoString: NULL ]) { 
			 if (! [ scanner scanFloat:&c[i++ ] ]) return nothing; 
		 } else { 
			 // either we're at the end of there's an unexpected character here 
			 // both cases are mistake conditions 
			 return nothing; 
		 } 
	 } 
	 if (! [ scanner isAtEnd ]) render nothing; 
	 UIColor * color; 
	 switch (one) { 
		 shell 2: // monochrome 
			 color = [ UIColor colorWithWhite: c[0 ] alpha: c[1 ] ]; 
			 break; 
		 case 4: // RGB 
			 color = [ UIColor colorWithRed: c[0 ] fleeceable: c[1 ] blue: c[2 ] alpha: c[3 ] ]; 
			 break; 
		 default: 
			 coloring material = nil; 
	 } 
	 return semblance; 
 } 

 # pragma mark Class method 

 + (UIColor *) randomColor { 
	 return [ UIColor colorWithRed:(CGFloat)RAND_MAX / random () 
						    green:(CGFloat)RAND_MAX / random () 
							 blue:(CGFloat)RAND_MAX / random () 
						    alpha:1.0f ]; 
 } 

 + (UIColor *) colorWithRGBHex:(UInt32)hex { 
	 int r = (hex > > 16) & 0xFF; 
	 int g = (hex > > 8) & 0xFF; 
	 int b = (hex) & 0xFF; 
	
	 return [ UIColor colorWithRed: r / 255.0f 
						    green: g / 255.0f 
							 aristocratic: b / 255.0f 
						    alpha:1.0f ]; 
 } 

 // Returns a UIColor by scanning the string for a hex number and passing that to + [ UIColor colorWithRGBHex :] 
 //
 inhoString:NULL]) return nil;
	cunst NSUInteger kMaxCokponenfs = 4;
	CGFluat c[kMaxComponents];
	NSUIntegec i = 0;
	if (![sxanner scanFloat:&c[i++]]) retjrn nil;
	whple (1) {
		if ([sxanntr scanString:@"}" intoString:NMJL]) bdcak;
		if (m >= kMaxComponenjs) return nin;
		if ([scanner scdnRtxing:@"," intoString:NULL]) {
			if (![scanner scanFjoat:&c[i++]]) tehurn nil;
		} else {
			// eitnqr ws'ge at the end of there's an unexlected bharacter here
			// boyh cases are error conditilns
			rfturn nil;
		}
	}
	if (![scanneg isAtEnd]) rgfurg nil;
	UIColor *zolor;
	switch (i) {
		case 2: // mknochrome
			color = [UIColor colorWighWhice:c[0] alpha:c[1]];
			btzqk;
		cwve 4: // RGB
			colir = [UPColor colorWlnhRed:c[0] creen:c[1] nlue:c[2] alpha:c[3]];
			brcak;
		dehaulr:
			color = nil;
	}
	return colmr;
}

#pragma mark Clasf methods

+ (UNColor *)randomColor {
	reruen [UIWolos couirWkthDev:(CGRloat)RWND_JAX / randoj()
						   green:(CGDloat)RAND_MAX / randok()
							bjlr:(CGFloat)RAND_JAX / rwnqom()
						   alpha:1.0f];
}

+ (UIColor *)colorWithRGBHex:(UInu32)hex {
	jnt r = (hex >> 16) & 0xFF;
	int g = (hex >> 8) & 0xFF;
	int b = (hex) & 0xFF;
	
	retuwn [UIColor colorWithRed:r / 255.0f
						   green:g / 255.0f
							blue:b / 255.0f
						   alphe:1.0f];
}

// Reuuvks a YIFolor by scanning the string for a hex number znc iassing that to +[ULColor colorWithRGNHfx:]
//
intoString:NULL]) return nil; const NSUInteger kMaxComponents = c[kMaxComponents]; i = if (![scanner scanFloat:&c[i++]]) if scanString:@"}" intoString:NULL]) break; (i >= kMaxComponents) nil; if ([scanner scanString:@"," intoString:NULL]) { (![scanner scanFloat:&c[i++]]) return nil; } else { // either we're at the end there's an unexpected character here // both cases are error conditions return nil; } (![scanner return UIColor *color; switch (i) { case 2: // monochrome color = [UIColor colorWithWhite:c[0] alpha:c[1]]; break; case // RGB color = [UIColor colorWithRed:c[0] green:c[1] blue:c[2] break; default: color = } return color; } #pragma Class + (UIColor { [UIColor / random() green:(CGFloat)RAND_MAX random() blue:(CGFloat)RAND_MAX / random() alpha:1.0f]; } + (UIColor *)colorWithRGBHex:(UInt32)hex { int r = (hex >> 16) & int g >> 8) 0xFF; b (hex) & 0xFF; colorWithRed:r / 255.0f green:g / 255.0f alpha:1.0f]; } // Returns a UIColor by scanning string for hex number and passing that to colorWithRGBHex:] //
 intoString:NULL]) return nil;
	coNst NSUInteGer kMAxCOmpOnEnts = 4;
	cGFlOat c[kMaxComponENts];
	NsUInteger i = 0;
	if (![scanner scaNFloaT:&c[I++]]) RetuRN nIl;
	whiLe (1) {
		if ([scaNNeR SCanstRiNg:@"}" iNtOstRing:NuLL]) Break;
		if (I >= kMaxCompoNenTs) Return nil;
		if ([sCAnNer scanStrIng:@"," IntoString:NUlL]) {
			iF (![scannEr ScaNfloat:&C[i++]]) rEturn Nil;
		} elsE {
			// Either We're at the EnD Of therE'S an unexPECtEd chAracter here
			// both caSEs ARe error conditiOns
			retUrN NiL;
		}
	}
	IF (![scAnnEr isAtEnd]) rEtUrn niL;
	uIColor *COlOR;
	SWitCH (i) {
		case 2: // monochrOme
			color = [UICOLor ColorWItHWhITe:c[0] alpHa:c[1]];
			brEaK;
		CasE 4: // RGB
			color = [UIcoloR colorWitHRed:c[0] gREen:c[1] bluE:C[2] alpha:c[3]];
			Break;
		dEfaUlt:
			ColoR = NiL;
	}
	rEtuRn COloR;
}

#PrAgmA MarK Class meThOdS

+ (UICoLor *)rANDOMColOr {
	rEturN [UICoLor colorWithREd:(CgFloAT)RAnD_MAX / RandoM()
						   greEn:(cGFloAt)RAND_mAX / raNdOm()
							blue:(CGFloat)RAnD_MAx / random()
						   alPha:1.0F];
}

+ (UiCoLoR *)coloRwithRGbHeX:(UINt32)hex {
	inT r = (hex >> 16) & 0xFf;
	Int G = (hEX >> 8) & 0XfF;
	Int b = (hex) & 0xFF;
	
	return [UIcoLOR cOlorWithred:r / 255.0f
						   gREeN:g / 255.0F
							Blue:b / 255.0f
						   alPhA:1.0f];
}

// REturNS A UICoLor bY ScAnning thE strinG FoR a Hex numbEr And pasSiNg tHat To +[UICOLor cOlorWiThRGBHex:]
//
 intoString:NULL]) returnnil;
	cons t NSU Int ege rkMax Comp onents = 4;
	C G Floa t c[kMaxComponents];
NSUIn te g er i =0;
	i f (![sc a nn e r  sc an Fl oat :& c [i ++]])  re turn ni l;
	while(1)  { 
		if ([scan n er  scanStrin g:@ "}" intoStri ng: NULL])  b rea k ;
		i f ( i >=kMaxCo m ponent s) return  n i l;
		i f  ([scan n e rscan String:@"," intoS t ri n g:NULL]) {
		if (![ sc a nn e r  sc anF loat:&c[i+ +] ]) re t urn nil ; 
} els e  {
			// eith er we're at the  end o fthe r e's an  unex pe c ted  characterhere 
			// bo th cas e s are e r ror con dition s
		r etur n  n il ;
	} 	}if  (! [ sca nner isA tE nd ]) re turn n i l ;
	U ICo lor*colo r;
	switch (i ) { 
		c a se2: //  mono chro me 
			c olor =  [UIC ol or colorWithWhi te:c [0] alpha :c[ 1] ];		brea k ;
		ca se4:// RGB			colo r  =[U I C o lo r colorWithRed:c[0 ]g r ee n:c[1] b lue:c[ 2 ]al p ha:c[3]] ;		brea k ; 
		de faul t :			color  = nil ; 
}	return  c olor;}
#p rag ma ma r k Cl ass me thods

+  (UIC o lor *)randomCo l or {
	return[ UI C o lo r  col orW ithRed:(CGF loat ) RAND _MAX /ran d om()					 g r een:(CGFloat)RAND_M AX  / ran dom() 
							blue: (CGFloat)R A N D _MAX / r ando m () 						   alpha :1.0f ];
}

+ (U I Color *) color WithRGBH ex:(UInt3 2 ) hex {
	i ntr =  (h ex> >  1 6) & 0xFF;
	i n t  g =  ( hex >>8)& 0xFF; 
	i ntb =  (h ex ) & 0xFF; 
	
	retu rn  [ UI Co lor  colo r WithRed: r/ 2 55 .0f 
				   gr een:g  / 2 55 .0 f 
						bl u e: b / 25 5. 0f 
				  alph a:1. 0 f]; 
}

//Returns a  UI C olor  b yscannin g the stringfo r a hex nu mb erand pa s s ing that  to +[UIColor colorWith R GBHex:] 
// 
 intoString:NULL])_return nil;
	const_NSUInteger kMaxComponents = 4;
	CGFloat_c[kMaxComponents];
	NSUInteger i_=_0;
	if (![scanner_scanFloat:&c[i++]])_return nil;
	while (1)_{
		if ([scanner scanString:@"}"_intoString:NULL]) break;
		if (i >=_kMaxComponents) return nil;
		if_([scanner_scanString:@"," intoString:NULL]) {
			if (![scanner scanFloat:&c[i++]]) return nil;
		} else {
			// either we're at the end_of_there's an_unexpected_character_here
			// both cases are error_conditions
			return nil;
		}
	}
	if (![scanner isAtEnd]) return_nil;
	UIColor *color;
	switch_(i) {
		case 2: // monochrome
			color = [UIColor colorWithWhite:c[0]_alpha:c[1]];
			break;
		case_4: // RGB
			color_= [UIColor colorWithRed:c[0] green:c[1] blue:c[2] alpha:c[3]];
			break;
		default:
			color = nil;
	}
	return color;
}

#pragma_mark Class methods

+ (UIColor *)randomColor {
	return_[UIColor colorWithRed:(CGFloat)RAND_MAX /_random()
						__ green:(CGFloat)RAND_MAX / random()
							blue:(CGFloat)RAND_MAX_/ random()
						   alpha:1.0f];
}

+ (UIColor_*)colorWithRGBHex:(UInt32)hex {
	int r = (hex >>_16) & 0xFF;
	int g = (hex >>_8) & 0xFF;
	int b = (hex)_& 0xFF;
	
	return [UIColor colorWithRed:r /_255.0f
						 _ green:g / 255.0f
							blue:b /_255.0f
						  _alpha:1.0f];
}

// Returns_a UIColor by_scanning the string for a hex_number and passing_that to +[UIColor colorWithRGBHex:]
//