I am trying to create a cydia tweak which changes some methods in a game
But I am always getting this error
control reaches end of non-void function
Here are the codes from my Tweak.xm(I shortened them down to where the errors are occurring at)
%hook Player
-(void)Jump:(int)jump {
if ((Upgrade = YES)) {
jump = 1;
%orig(jump);
}
else {
%orig;
}
}
-(int)GetSkill {
if ((Upgrade = YES)) {
return 1;
}
else {
%orig;
}
}
%end
%hook MainLayer
-(int)GetSkill:(int)skill {
if ((Upgrade = YES)) {
skill = 1;
%orig(skill);
}
else {
%orig;
}
}
%end
I have no idea why isn't the code block is not working. Sorry about that
Pls help me here, although it is a warning The codes still seems to change the game even if I click No in the Alert
your function -(int)GetSkill:(int)skill
has a return type of int
specified yet you dont have a return
statement. make it a (void)
if its not meant to return anything
if you have a return
inside an if statement, there has to be at least 1 return in the if
and the else
part for it to be able to return always, if not, it will give you that warning
side note: this statement if ((Upgrade = YES))
will always be true, since it is assigning Upgrade
instead of doing a comparison, you probably want to change it to if ((Upgrade == YES))