This is our last part of the tutorial. We have done whatever that needs to be done with respect to the UI. All that is left is the coding part. In the last post, you would have seen that we had a couple of methods defined called as updateResult() and range(). These are supposed to be private methods. But then, I don't want to overload the readers with that concept yet, hence I have not set the access modifier for them. They will come in handy in our implementation part.
The implementation part involves responding to the actions that are sent from the UI. Lets take a look at the implementation of the height slider and go line by line.
The first line is nothing but a copy of the method declaration. The return type of the this method is an IBAction. The argument that it takes is the sender's object. If you had known Java, 'id' is a data type similar to Object. It is the sender's object. Since we have attached this method with the Slider, this would be the Slider itself.
On the fist line inside the method, we are typecasting the sender to the UISlider since we know for sure that the sender is an instance of UISlider. We then get its value, asssign it to a NSString variable followed by assigning it to the height text. Since we have allocated the NSString we should release it. You could notice there is a tiny little call to updateResults. It is nothing but updating the BMI and the Result at the bottom. Its implemenation is,
The above code is self explanatory and straightforward to read. We also need to add a similar slider method for weight as we did for height.
Whoof thats a lotta coding. Lets see the final output in the final part of this tutorial!
Cheers!
Braga
The implementation part involves responding to the actions that are sent from the UI. Lets take a look at the implementation of the height slider and go line by line.
The first line is nothing but a copy of the method declaration. The return type of the this method is an IBAction. The argument that it takes is the sender's object. If you had known Java, 'id' is a data type similar to Object. It is the sender's object. Since we have attached this method with the Slider, this would be the Slider itself.
On the fist line inside the method, we are typecasting the sender to the UISlider since we know for sure that the sender is an instance of UISlider. We then get its value, asssign it to a NSString variable followed by assigning it to the height text. Since we have allocated the NSString we should release it. You could notice there is a tiny little call to updateResults. It is nothing but updating the BMI and the Result at the bottom. Its implemenation is,
The above code is self explanatory and straightforward to read. We also need to add a similar slider method for weight as we did for height.
Whoof thats a lotta coding. Lets see the final output in the final part of this tutorial!
Cheers!
Braga
2 comments:
Body weight of a person is theoretically the weight of the person without any items on. However, for all practical purposes, body weight is taken with clothes on but often without the shoes and heavy accessories like mobile phones and wallets. Thanks.
Regards,
hcg1234.com
The body mass Index is a great way to find out if you are underweight , overweight , or if you are at your ideal weight for your height and age.
Thanks a lot.
Regards,
how to gain weight
Post a Comment