neWRadmonArray = [[NSMutableArray alloc] init];
RadmonArray = [[NSMutableArray alloc] init];
[RadmonArray addObject: @ "A"];
[RadmonArray addObject: @ "B"];
[RadmonArray addObject: @ "C"];
[RadmonArray addObject: @ "D"];
[RadmonArray addObject: @ "E"];
I immediately removed from RadmonArray a
- (NSString *) GenerateRandom {
int randomValue = arc4random ()% 5 ;/ / Generate 0 - 4
NSString * returnRandom = [RadmonArray objectAtIndex: randomValue];
int i;
int total;
bool existFlag = false;
if (returnRandom == @ "A" && hasGenerateBlue == true) {
[Self GenerateRandom];
}
for (i = 0, total = [neWRadmonArray count]; i
if (returnRandom == [neWRadmonArray objectAtIndex: i]) {
existFlag = true;
break;
}
}
if (existFlag) / / check if has generated.
{
[Self GenerateRandom];
}
else
{
[NeWRadmonArray addObject: returnRandom] ;/ / put generated shape into array
}
return returnRandom;
}
But still a duplicate. . . Help us to see,,,
Reply:
This code is found the problem: nsstring record multiple values, but exactly how to change it. . .
Reply:
if (existFlag) / / check if has generated.
{
[Self GenerateRandom];
}
else
{
[NeWRadmonArray addObject: returnRandom] ;/ / put generated shape into array
}
return returnRandom; felt like here's why, if it exists, it will call itself a function, when the execution is not finished [self GenerateRandom]; then it will continue to perform the back, behind the return returnRandom, the return is not your call [self Gen ... dom] something in return, this time you call this function but returns initially given, it should return you want is not recursive call [self GeneratRandom] method returns value
Reply:
int randomValue = arc4random ()% 5 ;/ / Generate 0 - 4
NSString * returnRandom = [RadmonArray objectAtIndex: randomValue];
int i;
int total;
bool existFlag = false;
if (returnRandom == @ "A" && hasGenerateBlue == true) {
[Self GenerateRandom];
}
for (i = 0, total = [neWRadmonArray count]; i
if (returnRandom == [neWRadmonArray objectAtIndex: i]) {
existFlag = true;
break;
}
}
if (existFlag) / / check if has generated.
{/ / Here's what you call itself, which is equivalent to the function and contents once,
int randomValue = arc4random ()% 5 ;/ / Generate 0 - 4
NSString * returnRandom2222 = [RadmonArray objectAtIndex: randomValue];
int i;
int total;
bool existFlag = false;
if (returnRandom == @ "A" && hasGenerateBlue == true) {
[Self GenerateRandom];
}
for (i = 0, total = [neWRadmonArray count]; i
if (returnRandom == [neWRadmonArray objectAtIndex: i]) {
existFlag = true;
break;
}
}
if (existFlag) / / check if has generated.
{
[Self GenerateRandom];
}
else
{
[NeWRadmonArray addObject: returnRandom] ;/ / put generated shape into array
}
return returnRandom; / / Here is what you want, it is this if statement method calls itself again and got a returnRandom2
}
}
else
{
[NeWRadmonArray addObject: returnRandom] ;/ / put generated shape into array
}
return returnRandom ;/ / But here is what you call this method in other ways in the real return. Or did not initially make exitsFlag false values that have been in the
in newArray}
Reply:
if (existFlag) / / check if has generated.
{
[Self GenerateRandom];
}
else
{
[NeWRadmonArray addObject: returnRandom] ;/ / put generated shape into array
}
return returnRandom;
}
And you have a problem estimate this code, generateRandom there is a return value, how assignments are not in front of the object? ? ? ?
Changed if (existFlag) / / check if has generated.
{
returnRandom = [self GenerateRandom];
}
Then try the next
No comments:
Post a Comment