I’m developing word puzzle game,where one word is given.according to that word the random letters are generated…for that, i applied below logic but some how the random letters not generated as per the given word.
NSMutableArray *ArrOfABCD = [[NSMutableArray alloc] initWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z", nil];
float x = 70; float y = 100; float width = 30; float height = 20; for(int i =0;i<32;i++) { NSUInteger randomIndex = arc4random() %(ArrOfABCD.count); UIButton *btnLetter = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [btnLetter setFrame:CGRectMake(x, y, width, height)]; [btnLetter setTitle:[NSString stringWithFormat:@"%@",ArrOfABCD[randomIndex]]
forState:UIControlStateNormal]; [self.view addSubview:btnLetter];
x = x + width + 30; if((i+1)%4==0) { x = 70; y = y + height + 20; } }
can any one suggest me that where i made mistake?