objective c - Always returning null in NSString return function -



objective c - Always returning null in NSString return function -

i have next code want convert decimal odds fractional odds. function findnearestwholeinteger returns null.

- (nsstring *)displayoddwithformat:(nsstring *)decimalodd { if ([[nsuserdefaults standarduserdefaults] boolforkey:@"fractionalodds"] == yes) { float oddsf = decimalodd.floatvalue; oddsf = oddsf - 1.0f; homecoming [self findnearestwholeinteger:oddsf andinitial:oddsf andbottom:1]; } else { homecoming odd; } } - (nsstring *)findnearestwholeinteger:(float)odds andinitial:(float)initial andbottom:(float)bottom { nsnumber *numbervalue = [nsnumber numberwithfloat:odds]; nsstring *floatstring = [numbervalue stringvalue]; nsarray *floatstringcomps = [floatstring componentsseparatedbystring:@"."]; if (floatstringcomps.count == 1) { homecoming [nsstring stringwithformat:@"%.f/%.f", odds, bottom]; } else { bottom += 1; odds += initial; [self findnearestwholeinteger:odds andinitial:initial andbottom:bottom]; homecoming nil; } }

any ideas need adapt code? in advance!

don't want:

return [self findnearestwholeinteger:odds andinitial:initial andbottom:bottom]; //return nil;

(not understand method doing).

objective-c

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -