Tag Archives: Programming

Doing Math in Objective C

Share this:  


One thing you will find you need to do in any programming language is do math. Here are some useful math functions for the Objective C language. I give a little bit of a comparison to Visual Basic for those who know that language. They are provided in no special order:

  • fabs() – Gets the absolute value of the value in parentheses. Works like ABS() function in Visual Basic. fabs(-123) = 123, fabs(34) = 34.
  • ceil() – Find the ceiling integer. Kind of like rounding up. Same as INT(x+1) in Visual Basic.  ceil(3.1) = 4.
  • floor() – Find the floor integer. Kind of like rounding down. Same as INT(x) in Visual Basic. floor(3.6) = 3.
  • exp() – Find the exponential value.
  • pow() – Raise a number to the power. pow(3,6) = 3^6 in Visual Basic.
  • rand() – Generate a pseudo random number. Function is RND(x) in Visual Basic. A good discussion on random numbers in Objective C can be found here.
  • srandom() – Generate a seed for the random number generator. This is done with the Randomize statement in Visual Basic.
  • sqrt() – Find out the square root of a number. sqrt(x) = x^(1/2) in Visual Basic.

Javascript: The Good Parts – A Collection of Lectures By Douglas Crockford on the Javascript Language

Share this:  

A few years ago, I am not sure just when or how, I stumbled upon these videos on Yahoo where programming legend Douglas Crockford gave very interesting and insightful lectures on the JavaScript language. It has been a bit tedious to find part X of a lecture and I would think about creating a page on the web that embeds all these videos in a way that makes watching them easier to do. To curate this content as Robert Scoble might say. Well after all this time I am doing just that in this post.  I think that if you are a programmer and you use JavaScript in any fashion that this information is really useful. Both to learn new things, as well as for review. Read more

How to Create Class Categories in Objective C

Share this:  


Note: Video is Best Viewed in Full Screen Mode

As I began refining some sample code for making Universal Apps for the iPhone and iPad, I sought a way to make my code as concise as possible. I needed to determine if the app was running on an iPad or iPhone/iPod Touch and use it to my advantage. This basic information is contained in the UIDevice class.

Unfortunately, using:

Read more