Ready to Level-Up?

This just in! If your rusty iOS skills could use some refining, or if you're just starting out and you want to level-up fast, consider signing up for our upcoming iOS Screencasts

New from iOS Rocket Surgery Swift Video Tutorials: The rapidly evolving Apple-iOS ecosystem has just been thrown into tumult with the recent introduction of the Swift Programming Language. Are you ready to finally try iOS development? Are you needing to switch from Objective-C to Swift? Sign up today for our free video courses!
(By the dear folks at Swift Tutorial Videos, a sister company)

Thursday, October 31, 2013

NSInteger to int

So, you want to convert an NSInteger to an int do you?

Somewhere there is a developer who is at the end of their tolerance for the querks of a language or an SDK. Somewhere, someone is begging for consistency in converting objects to primitives. We have NSStrings that have built-in methods for converting to primitives, so what the heck is wrong with my NSInteger class? There's no [NSInteger intValue] method!

Well, the answer is:

  NSInteger *currentPage = 42;
  int myInt = currentPage;

... apparently not that complicated.

{Sigh} For the purpose of calculations, you can treat NSIntegers as being barely anything more than 32 or 64 bit integers in disguise. 

Now go,  and bring glory to the house of your kinsmen!




About Me

Easy NSDateFormatter Tool

Save yourself some time in formatting your NSDates to NSStrings, and use the Blind NSDate app, which you can download from iTunes. There's also a website where you can format your NSDates: http://www.blindnsdate.com

Popular Posts

Designed By Seo Blogger Templates