iPhone Code Snippets & Tutorials

Memory management is arguably the most difficult concept for beginner programmers to grasp. When I decided to go back to school, I was required to take beginner programming classes since there is no option to test in to computer science courses. I witnessed the hair-pulling frustration of the beginner students when memory management was introduced for the first time. The hardest part of that course was when I was asked to act as a sort of student teacher-aid, going around helping trying to help other students learn memory management.

Luckily, an author going by r_adem has released an excellent article explaining proper memory management on iOS. There are several snippets with detailed explanations outlining when and why you would use certain memory management methods.

He shows the right way and the wrong way to manage memory, both with code snippets. Check it out, and thanks to John Dowa at ManiacDev for the link, which can be found below.

[Via: ManiacDev.com]
[Link: How to avoid memory leaks in iPhone applications]

Here’s the deal. I wrote a bit of sample code to generate 2D terrain. (See here and here) A fellow blogger and reader pointed out a performance flaw to me and suggested I do it differently. So I did. With problems.

I’m usually posting tips and help to readers, and it’s your turn to return the favor, if you would be so kind. Find the flaw, win an ‘atta boy, pat on the back, and a thank you. Sorry, no prizes. (more…)

Here is some iOS code that allows you to generate your own terrain in a 2d iPhone side-scrolling style game by simply dragging your finger up and down. The possible potential uses are endless. This code uses Cocos2D.




(more…)

Ask any developer of fast-paced iPhone games what language they use and none will say Objective-C. I am not referring to card games, or simple games like SpaceBubble. I am talking about processor intensive, special effects, things flying at you from all angles, kind of games. Of course every iPhone game has to use SOME Objective-C to get the app up and running and for certain API calls, but those kinds of things should not take up more than a few hundred lines of code at most in a large game.
(more…)

In this tutorial we will expand on the previous Core Location tutorial. Here we will extract specific location attributes such as coordinates, altitude, and speed.



(more…)

Core Location is a powerful yet simple iOS framework allowing easy access to the iPhone’s GPS. You can access the coordinates of the device with GPS or cell triangulation, compass, and direction and speed of travel.

Apple’s description:

The Core Location framework lets you determine the current location or heading associated with a device. The framework uses the available hardware to determine the user’s position and heading. You use the classes and protocols in this framework to configure and schedule the delivery of location and heading events. You can also use it to define geographic regions and monitor when the user crosses the boundaries of those regions.

In this tutorial you will learn how to access the raw Core Location data, including the iPhone’s GPS coordinates and speed of travel. (more…)

I started to write a tutorial today but got a bit burned out in the process. I will finish it eventually, but here is the code for you to tinker with in the meantime.

The code demonstrates Core Location and makes use of custom protocols. The app updates a UILabel with GPS coordinates and speed of travel. Stay tuned, the tutorial will be finished up shortly!


[Source: CoreLocation GPS Demo - 25k]

As I eventually do with just about all my code, I am releasing iStrobe’s innards to the public. It’s yours, take it. Make sure to abide by the rules though.

Download:
iStrobe Source Code for iPhone 4 – 1.4MB
[App Store: Get It Here]


I updated SpaceBubble to support iAds a while ago but haven’t gotten around to uploading the new code. This is good, because I found a bug in the meantime. This is for the unreleased version which is still in review with all bugs fixed. Enjoy!




Here is the updated Objective-C source code to my iPhone game SpaceBubble! (more…)

The minimum donation requirement to receive a copy of iStrobe’s source code has dropped. Only $25 for licensed and for $100 no license, no restrictions.

Make a donation with the comment “iStrobe Source” and you will be emailed a copy. All donations help fund this site and any left over will help buy books for this coming semester of school. Thanks!

Twitter Me