Posts tagged ‘iPhone SDK’

Stanford iPhone App Programming lecture 10

Lecture 10 from the Stanford University iPhone Application Programming class was hosted by Alan Cannistraro. He covered memory and performance, two topics that are often overlooked when developing software for mobile devices.

His talk included a demonstration on using Instruments to find memory leaks and memory allocations, the dangers of autorelease objects, and using NSThread and an NSOperationQueue to keep the program running during blocking operations.

If I ever get a halfway functional iPhone app developed, the information about finding memory leaks and threading should prove very useful.

Stanford iPhone App Programming lecture 9

Lecture 9 from the Stanford University iPhone Application Programming class was hosted by Evan Doll, clad in another interesting t-shirt. His topic of the day was persisting data on the iPhone by the use of property lists and SQLite databases, and communicating with web services using the JSON framework.

His talk was incredibly informative and straightforward, and I thought the demos that he used emphasized his points perfectly. Specifically, he covered reading and writing arrays and dictionaries to the iPhone’s file system, use of the NSCoding protocol, basic SQLite operations, and a demo that showed using the json-framework to pull down data from the Flickr web site and display image search results in a list. Finally, at the end, Evan talked about passing data between objects (such as from a list controller to a detail view controller).

The SQLite information should prove extremely valuable, as I am going to want to do some data storage in my iPhone app that goes beyond simply storing preferences in the NSUserDefaults area.

Stanford iPhone App Programming lecture 8

Lecture 8 from the Stanford University iPhone Application Programming class was hosted by a guest speaker from Apple. The topic of the day was tables and table view controllers. Again, there was lots of good information in the class. I have not really worked yet with tables in my iPhone application development so far, but I’m sure once I do, this information will help out.

Stanford iPhone App Programming lectures 6 and 7

Lectures 6 and 7 from the Stanford University iPhone Application Programming class contain a lot of useful information regarding the theory and usage of view controllers in general and navigation controllers and tab bar controllers in specific.

It took a bit of digging to figure out what Evan Doll’s shirt said in lecture 7, but apparently there is a band out there called Blitzen Trapper.

Stanford iPhone App Programming lectures 4 and 5

I just finished going through lectures 4 and 5 of the iPhone Application Programming class from Stanford University, and learned some more new things that I did not know. Especially interesting was the Stalker demo application that they did at the end of lecture 5, it was kind a neat little demonstration of animating views.

Stanford University iPhone Application Programming class

I have been checking out some of the lecture videos for the Stanford University iPhone Application Programming class CS193P, and I think they are very well done. I have been doing iPhone development for a little while now, and even though I am familiar with quite a bit of what they are presenting, there are still some things in each lecture that I did not know or was not crystal clear on the concepts for.

Here is a link to the course page on Stanford’s web site:

CS 193P — iPhone Application Programming

In order to watch the videos of the lectures, you have to download them into your iTunes through iTunes U. There are also PDF files on the above web page that contain the slide presentations used during the lectures, along with the class assignments and other documents.

So far, I have gone though the first 3 lectures. They do move a bit slowly when questions bog down the presentation, but you can’t beat the price, and other than the first introductory lecture, there should be value in each lecture for most iPhone developers.

AudioServicesCreateSystemSoundID error -1500

The iPhone application is going along fine, and I decided to look into adding some sound to the application. So, I found a .caf sound file on my Macintosh, brought it into the project, and then used the SoundEffect class from the Metronome sample application.

Here is the initialization code that I am using:

theSound = [[SoundEffect alloc] initWithContentsOfFile:[mainBundle 
                pathForResource:@"soundfile" ofType:@"caf"]];

When running the application in the Simulator, everything worked fine and the sound played loud and clear. However, when running the application on an actual device, there was no sound to be heard. Stepping through the code, I traced the problem down to initWithContentsOfFile method of the SoundEffect class, which was returning an error -1500 on this line of code:

OSStatus error = AudioServicesCreateSystemSoundID((CFURLRef)aFileURL, &aSoundID);

After trying to solve the problem by poring over the code, I decided on a lark to try to use the same exact .caf file that the Metronome application used. Of course, this worked, which apparently means that if you get the error -1500 from the AudioServicesCreateSystemSoundID call, it is possible that you are using a sound file that is compatible with the Mac but not with the iPhone.

iPhone application based on the “Utility Application” template and the “i” (info) button

So you have created an amazing iPhone application and based it on the Utility Application template in the iPhone SDK. This template gives you a main view and an alternate view that you can use for preferences or other information. This alternate view is seen by tapping on the info button (which is a round graphical “i”)  in the bottom right corner of the main view.

The development is going like gangbusters, your application is looking real good. You have been developing and testing in the simulator and all is working fine.

But your world gets rocked when you put the application on an actual device. All of a sudden, no one can tap your “i” button, or it takes several tries to finally tap it to display the alternate view.

I feel your pain, as I found myself in the same exact situation.

Well I have found a solution. Apparently the bounding rectangle for the info button in the MainView.xib is pretty small, so I inserted the following code into the viewDidLoad method of RootViewController.m:

CGRect newInfoButtonRect = CGRectMake(infoButton.frame.origin.x - 20,
                            infoButton.frame.origin.y - 20,
                            infoButton.frame.size.width + 40,
                            infoButton.frame.size.height + 40);
[infoButton setFrame:newInfoButtonRect];

Now the info button works every single time.

But I cannot take the credit, here is the link that led me to this solution:

Problem with infoButton on Utility based app (link redacted)