Search Results

Search found 2 results on 1 pages for 'dipu'.

Page 1/1 | 1 

  • How can I convert RGB hex string into UIColor in objective-c?

    - by dipu
    I have color values coming from the url data is like this, "#ff33cc". How can I convert this value into UIColor? I am attempting with the following lines of code. I am not getting the value for baseColor1 right. Looks like I should take that pound char off. Is there another way to do it? NSScanner *scanner2 = [NSScanner scannerWithString:@"#ff33cc"]; int baseColor1; [scanner2 scanHexInt:&baseColor1]; CGFloat red = (baseColor1 & 0xFF0000); [UIColor colorWithRed:red ...

    Read the article

  • Is this a correct porting of java.util.Random in objectiveC

    - by dipu
    I have ported the code inside java.util.Random class in objectivec. I want to have an identical random number generator so that it synchs with the server app running on java. Now is this a safe porting and if not is there a way to mimic AtomicLong as it is found in java? Please see my code below. static long long multiplier = 0x5DEECE66DL; static long addend = 0xBL; static long long mask = (0x1000000000000001L << 48) - 1; -(void) initWithSeed:(long long) seed1 { [self setRandomSeed: 0L];// = new AtomicLong(0L); [self setSeed: seed1]; } -(int) next:(int)bits { long long oldseed, nextseed; long long seed1 = [self.randomSeed longLongValue]; //AtomicLong //do { oldseed = seed1; nextseed = (oldseed * multiplier + addend) & mask; //} while (!seed.compareAndSet(oldseed, nextseed)); [self setRandomSeed: [NSNumber numberWithLongLong:nextseed]]; ///int ret = (int)(nextseed >>> (48 - bits)); int ret = (unsigned int)(nextseed >> (48 - bits)); return ret; } -(void) setSeed:(long long) seed1 { seed1 = (seed1 ^ multiplier) & mask; [self setRandomSeed: [NSNumber numberWithLongLong:seed1]]; }

    Read the article

1