objective c - Increasing integerValue of UITextField -
the completion code of code animates squareone
. when clicked becomes hidden. if index of image squareone
uses, same icon
, if squareone
hidden, animation repeats. (this condition want score increase on). if squareone
isn't clicked @ still repeat.
completion:^(bool complete) { if (complete) { [self squareonecolour]; [self squareonemover]; if (self.squareone.hidden==yes) { if (a==b) { [self squareonecolour]; [self squareonemover]; //i want score increase here } else if (a!=b) { [self squareonecolour]; [self squareonemover]; nslog(@"square 1 isn't supposed pressed"); }}}}];} //just make more compact
when try doing create dozens of nsstring
, nsuinteger
variable , think way inefficient, , doesn't work... can me integervalue
of textfield score
increase every time squareone
pressed , matches image on icon
?
how using:
mytextfield.text = @(_mytextfield.text.integervalue + 1).stringvalue;
what we're doing is:
- get integervalue text field , add 1
- set value on text field's text peroperty, boxing nsnumber (using '@') , call stringvalue method on it.
regarding code formatting:
- i recommend not use trailing comments, eg
foo += 5 //add foo-tax
. rationale developers can waste time getting trailing comments line , formatted nicely. common 'lint' check in code quality tools. - don't pack of braces 1 line. it's best stick formatting conventions.
Comments
Post a Comment