Wednesday, December 1, 2010

A New Home for my iPhone Obsessed-Like Posts

I just created a post on how to fix a Base SDK Missing error... but not here on iPhone Obsessed. But rather on chomer.com, my main site.

I must say that I have wanted for quite some time now to be posting everything I write on my main site. This means iPhone or iPad related posts as well as any other subject I choose to write on. But quite frankly I was rather embarrassed with the state that my "official" web site was in and thought it might drive people away if they saw it!

Well, now after working on and off on my site for a while now, I think I am happy with it and feel confident that it is where I want to "put down roots" on the Internet!

From now on I plan to post all my content on the iPhone/iPad, and iOS programming there instead. If you are subscribed to Feedburner for iPhone Obsessed I would suggest subscribing to Feedburner for Chomer.com so you can be informed of all the latest posts!

What kind of things can you expect?
  • General information articles on the iPhone and iPad.
  • iOS SDK development information.
  • Information on Objective C.
  • Programming information/tips on other platforms/programming languages.
  • Freeware.
  • Open source code.
  • Techie and geeky type things.
  • Information on other tangents of mine every now and then.
  • I plan to steadily build up the content on the site on a regular basis.
A few more things I'll mention:
  • I have moved quite a few articles from iPhone Obsessed over to Chomer.com.
  • There was already quite a few articles on programming on Chomer.com covering such subjects as VBA and more.
  • You can download a freeware version of a solitaire Mahjongg game that I wrote some time back. Sadly this game only works on a Windows platform. But it works pretty well.

Sunday, May 16, 2010

Tutorial: Creating Class Categories in Objective C

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:

         [UIDevice currentDevice].model    

did not do precisely what I needed to do. I needed something specialized. I wanted to add new functionality to the UIDevice class as if it had been there all along.

Looking for Solutions
A few months back I ran into a code sample that adds functionality to the NSDate class called NSDate+Helper. This class, created by a programmer named Billy Gray was my first exposure to a wonderful feature built into Objective C called Class Categories. When I saw how one could do this, it set the wheels turning in my mind at all the possibilities!

In this tutorial I am going to show you how to use class categories, and for our example we are going to add functionality to the UIDevice class for use in ultimately creating a sample Universal App.

Note: The tutorial video appears below. If you are reading this post from a feed that does not support showing the embedded video click here to jump directly to this post on iPhone Obsessed.

note that the above video contents are easier to see in full screen mode.

Sample Code Info:

Getting Sample Project Source Code & Running it in the Simulator
It would be handy for you to download a copy of our Universal App project to look over and try out. In order to really use it you will need to have an Intel-based Mac computer, and XCode 3.2 or better installed on it. Once you have done this,  you will be able to run it in the iPhone Simulator.

Make sure when running on the simulator that you set the proper build version before doing a build:

Simulating the app running on an iPhone:

Simulating the app running on an iPad:

Running the Sample Project on an Actual Device
If you want to run the project on an actual device rather than just the simulator, you will need to be a paying member of the Apple Developer Network ($99 a year at the time of this post). And you will need to have gone through the hoops of setting up your certificates, app record, and provisioning. ... We are not covering any of this getting on the device stuff in this tutorial.

At least you can run the project in the iPhone Simulator for free! 

Getting In Class Categories

What is a Class Category?
  • You use class categories to add new functionality to an existing class. This could be one of your own classes, or it could be a class in Apple or someone else's API.
  • You do not have to sub-class the class you are adding to.
  • You can add the new functionality in such a way (inside your project) that it seems that the functionality was there all along!

Step 1: Come Up With A Category Name
When creating a class category you are adding some sort of new functionality to an existing class (without touching any of the code actually in the existing class)! If you were to describe in a general way what that new functionality was, how would you phrase it? What "category" would it fall under?  This is something you make up. I make up some sort of camel-cased phrase for my category name. In the case of my new functionality to add to UIDevice, I thought that MyDeviceType captured it well. Perhaps if I had thought about it longer I could have made up something better! But that is what I came up with so that is what I used!

Step 2: Create a Group in Our Project to Place our Class Category in (optional)
The first thing you may want to do is create a new group (folder in your project) to place it in. This is optional, but it can make finding it easier as well as providing some form of internal documentation.

So, for the sake of argument, let's say that this is what you want to do. Let's go through the steps needed to do this:
- First of all click on your project file item (in examples shown in the screen shots, this is "classcat").
- Then control-click on it again to bring up a pop-up menu.
- Click the Add option at the top of the menu...
- Then click the New Group option (see screen shot below)
At this point you will see a new group appear under classcat with the text highlighted and ready for you to edit like in the screen shot below:

Lets rename the group to "Class Categories"...

Step 3: Create a new Class from the NSObject Class
- Control-click on our Class Categories group to bring up the pop-up menu.
- Pick the Add option.
- Pick the New File... option.

- The New File dialog window will appear.
- Make sure that Cocoa Touch Class is highlighted on the left hand side.
- Make sure the Objective-C class option is selected.
- Make sure Subclass of is set to NSObject.
- Then click the Next button.

The next screen will come up. It is looking for you to name the class:

We need to enter our class name. Gotta have some sorta naming convention! We will use the name of the original class we are creating a category for followed by the name of the category itself. That sounds good! So the original class in our example is UIDevice. The name of our class category is going to be: MyDeviceType. So we will type in UIDeviceMyDeviceType.
Above I type in my new class name. Then I would just click the blue Finish button.

Here is the initial header file XCode created:

This file starts out as just a normal class being subclassed from a superclass (NSObject).

Step 4: Modify Our New Class Files and Turn them Into a Class Category
The first thing we will do here is replace the class name UIDeviceMyDeviceType with the class name we are creating a category for. In this case that is UIDevice.
Next we are going to put MyDeviceType in parenthesis and delete the colon, NSObject and the curly braces and end up with this:
- Again note that above UIDevice is the existing class we are creating a category for. 
- MyDeviceType is the category name we made up for our category.
- The category name is in parenthesis.
- Although it might seem that we should put the category name in quotes... we do not.
- Again, we removed the normally correct curly braces... to leave them in on our class category will get you errors when you build your project.

While we are at it, lets add some interface definitions for the methods in our class category that we want to make public:

There may be other members in our class category than these, but these are available to be used by the "outside world."

Now let's look at the implementation file (the .m file)...

Notice it has the class name we gave originally. After the text UIDevice, we need to put parenthesis around MyDeviceType... Again, no quotes go around the class category name.

There! It is now setup to be used as a class category! All that remains to be done is add any variable declarations and code for our members.

Here is a screen shot showing a partial view of what that could look like:

To see an actual working example download the Universal App sample code I have provided.

Step 5: Use New Functionality in Your Project!
The new functionality at this point is ready to be used. There are two ways to make it accessible to various classes in your project:

1. In the implementation file of a class that is going to use this functionality, add an #import line at the top. In our case the line would be:

     #import "UIDeviceMyDeviceType.h"

2. If you are going to use it widely in your project there is a better way! 
Click in the Other Sources group in the project and click on the classcat_Prefix.pch file.
(the first part of the file name is the project name).

You will see two import lines defined for Apple framework stuff. XCode puts these in so that the programmer does not have to use #import for anything in these frameworks throughout the project... the #import is implied. Underneath the #import add our import statement:

     #import "UIDeviceMyDeviceType.h"

Save your changes and BOOM! All your new functionality in your new class category is available to project!

You could say:

      NSString *myDev = [UIDevice myDeviceType];

 in your code anywhere in your project and the new myDeviceType method will just work!

Different Uses for Class Categories
Here are some possibilities to think about:
  • Add new functionality to existing classes (especially API type stuff) like we did in this tutorial.
  • Break a large class up into separate files grouping various blocks by function "category."
  • Can you think of anything else? :)
Hope you find this tutorial useful. Any questions? Ask away. If you could rate my Youtube video that would be great too! 

In the next tutorial we will be talking about the structure of a Universal App.

Tuesday, May 11, 2010

Tutorial: iPhone OS Templates in XCode Using the iPhone 3.2 SDK

I started working on a video tutorial on how to make a universal app which will run on both the iPhone/iPod Touch and the iPad. I began by describing all the different iPhone OS Templates and then focused in on the template to use to create what Apple calls Universal Apps.

Going through this exercise took more time than I really wanted to spend so I decided to split that part out. The contents of this tutorial on iPhone OS Template may seem a little obvious... but sometimes the obvious seems to land right under our noses without us noticing.

That happened to me when I started looking into the process of creating universal apps. I missed out on the fact that I could use the windows based application template to do just that. So then what other options did I have as a developer regarding these templates? I did a little digging.

This tutorial is not earth shattering, but I think it is good preparation for getting into the subject of writing universal apps.

Saturday, May 1, 2010

The iPad 3G is Launched

Friday, April 30th, I took the day off in order that I could buy my very own iPad with 3G built in. I'd been showing some restraint. I had come close to just saying the heck with it I'll get the Wifi only version. But I toughed it out.

So I took the day off of work so that I could be there bright and early. I dropped my wife off at work so that I could have the car. But when I got to the store I found out that the new 3G iPads would not be going on sale until 5pm later that day! They were closing up the store an hour before the event to get ready. Pooh!

I decided to get all the accessories that I wanted for my new iPad right then and there and come back to purchase said device.

Getting the iPad
Well I got to the store there was a line of people snaking around patiently waiting for their turn to get their new Apple toy. Quite a few people there. This wasn't an Apple store in California, New York, or even a store like the one on Michigan Avenue in downtown Chicago, this was in a mall in Oak brook, Illinois. Must be all the geeks! Well... I'm one of them!

Apple employees making plans just before the
store opens for the special iPad event.
People waiting in line near the store entrance.

Another view of the line waiting at the Apple
Oakbrook store.

Picture taken near the end of the line where I wait for my 
chance to own an iPad 3G.

When the store opened and the first few people were picked to enter the store, the Apple employees cheered and applauded. I'm glad they just did this at the start or I would have been embarrassed. As Apple employees would become available they would come out of the store and get the next customer in line. Overall the buying experience was very good and the line moved along nicely. They were out of the low-end 16 Gb 3G models before I got to the front of the line!

And what did I get? The 64gig 3G model (which was what I had decided to get all along). 

Monday, April 12, 2010

Some Initial Thoughts on the iPad, and I've Published an iPad App in the App Store!

I'm waiting for the end of this month to buy the iPad with 3G built in. And yet I bought an iPad on Saturday! What gives? Sometimes I wonder myself! Well, I bought it as a gift for a friend who just had a birthday. And, I must confess, I wanted to play with it before I gave it away!

I can say I really like it a lot! The eBook reader is very cool. Doing a search in the bookstore for "free" brings up lots of titles that I would want to read. And...

And I got to test out the app I did for the iPad on it. I bought it from the App Store and tried it out. It was the first time I had ever run the app on an actual device! Before it was just using the iPad Simulator included in the SDK. That was very cool! The app is a 56 page long eBook full of poems called "I Lost My Underwear Today and other flights of imagination." The owner is charging $1.99 for it. Unlike just a plain ol' book, you not only see the pages of text and illustrations, you can hear the author reading each poem by pressing the Play button at the bottom of the page.

If you would do me a favor, go and buy it, read it, listen to it, rate it, and leave a review. The guy who wrote the book is a great guy and could use the revenue. I will not be receiving any money myself from the purchases.

Anyway, I took the paper version of the book and converted it into an iPad version, recorded the author reading his poems, and put the whole thing together. It was cool working on my first iPad app.

Also cool was seeing it in the App Store. Nice! This is my first app in there. I think this is rather funny for a couple reasons:
  • First, I've been working on and off on a couple of iPhone/iPod Touch apps on and off now for over a year and am still not finished. These apps will be published by me, and God willing, I will get the revenue from them after Apple gets their 30%. But this new app up now in iTunes isn't my app! I wrote it for someone else!
  • Second, even though I have run my own apps on my iPhone to test them, I never had a chance to with this new app. As mentioned before I ran it on a device only after it was in the App Store!
Some Other iPad Thoughts
Talking about something other than the iPad App I wrote (I admit I'm a little giddy), there are some other observations I want to mention about the iPad that I played with.

You can't just use it out of the box, you have to hook it up to your computer and fire up iTunes to set it up for the first time. If on a Mac, iTunes will probably come up automatically when you plug it in (but you probably already knew that).

Saying that thought, this configuration process is very fast and easy.

I did note that the battery was at about 86% right out of the box, so, if that is average, you can begin using it right away. No charging needed ahead of time.

The bookstore is really cool as mentioned before. A lot of the books that were free are classic that I have read and like, or ones that I want to read. I am a big book reader! Boy, I can't wait to get my own iPad at the end of this month!

Saturday, April 3, 2010

Apple Rolls Out the iPad

Today, was the day that Apple fans have been waiting for. The day the iPad finally went on sale. I went to Bally's to workout and then decided to head over to the nearest Apple store. My intentions were not to buy an iPad but merely see what was up, and try one out for myself. My plans were to buy the 3G version that is supposed to come out later this month.

I knew there would be lines at Apple stores in places like Palo Alto, San Francisco, and New York. I did not think there would be such a thing really at the store in Oak Brook, Illinois.

I got to the store around 1-1:30-ish in the afternoon. And the scene I saw is shown in the picture below:

Front of Apple Store for the iPad Release

The lines were gone by now, but I asked someone working at the store about them, and there was a fairly long line waiting outside, ready for the Apple store to open its doors. Even at the time I shot this picture with my iPhone the doors were propped wide open and people were spilling out of the store (its a little hard to see in this photo). And most of the people were towards the front (where the demo iPads were on display). All the Apple staff for the store were out in full force, and, even with all the people who showed up, there were plenty of staff members there to serve you and answer your questions.

The place had a festive atmosphere and I started getting strong urges to buy a Wifi only iPad right there on the spot!

At the tables where the tethered iPad demo units were on display, you actually had to stand in an impromptu line to get a chance to use one. I took the picture below as I was waiting to get my chance. I heard from one lady who worked there that there had been a customer who had hogged using one for nearly an hour! Fortunately for me, everyone I saw was polite and civil!
They look so thin! I was surprised that when I actually picked one up, it was heavier than it looked. But its still cool!

People Giving the iPad a Try

At the back of the store, behind the counter, they had iPad boxes stacked up in stack upon stack. Though most of them looked like they were reserved for people who pre-ordered.

No docking devices with or without keyboards were to be seen, but that was not surprising considering information on the web said they would come out later. What was surprising (at least to me) is that there were covers on sales for the iPad. These were supposed to be delayed too. But, at least in this store, they had plenty available. Below is a rather blurry picture I took of the covers for sales hanging on a display on the wall:

Blurry shot of iPad covers that are on sale

I came really close to buying one, but I walked out of the store escaping the energetic atmosphere of iPad seduction that permeated the place. Does that mean I'm not getting one?
Nope! I'm waiting... at least for now!

Friday, February 5, 2010

I want an iPad

Well, several days have gone by since Apple announced it's new tablet device the iPad. It seems that all that could be said about a device that we can't have yet has been said. The iPhone Obsessed blog has remained silent. Well one thing you didn't know before: I want one! Not that anyone cares but me! One thing that I have wished for when programming for the iPhone is more screen real estate. This cannot be underestimated in importance. The iPad addresses this problem in spades. So I talk here, hopefully providing just a slightly different angle of looking at a subject that has already been written about at length.

As I read all the buzz for the iPad: the initial disappointment after the device didn't meet people's heightened expectations due to all the hype, then the growing realization by developers that they have all this space to put their user interfaces in... I see others are focusing in on this advantage. Some say that "look, a laptop has a bigger screen." But a laptop computer does not have a touch screen. A laptop computer has this physical keyboard that gets in the way and makes it feel a bit awkward sitting on your lap. When I saw Steve Jobs during the key note sitting in the chair with the iPad in his lap just using it, it connected with me: This was precisely like how I would interact with a book or magazine, or a pad of paper. It is not almost there like a laptop computer is. The awkwardness has been completely removed.

Steve Jobs called it an "intimate" experience. I have to agree. It worked for him as a real-world, non-tech device would work, and has worked for thousands of years. In fact, it works better than books and magazines do (no more holding the page down to keep it from turning when you don't want it to, no more trying to put a crease in the page so it stays open... more like a clay tablet with ancient cuneiform written on it. A flat, single surface. The iPad is like that except its able to hold lots more information, does color, is back-lit, and is hooked up to the internet!

As for all the prognostication on how it will sell, and will Apple save the publishing industry, will the iPad bring world peace or feed starving children, I have no clue. But I know I want one, and am planning on buying one.

Monday, January 25, 2010

Thoughts Regarding the Applet Tablet

If you have been following anything tech lately, you've heard rumors of an Apple tablet device. Rumors about this device have been going on for years now, but it seems that sometime real soon now this device will actually become a reality.

This Wednesday Apple is announcing something. Everyone thinks and hopes its an Apple tablet. Including yours truly. What happens if Apple does not announce it? There are going to be some sad, disappointed, and frustrated people out there... including me! Can we honestly blame Apple? No, they never said that is what they were going to announce. Though frustrating, it would be humorous if no tablet device was announced. All these people, getting themselves all jacked up for a new product that only exists in their minds! Hey I admit it exists in my mind too.

What's funny to me is how I am dreaming up what kind of apps I could write for it and I haven't even finished up an app for the iPhone yet!

All in all though, I really do think it highly likely that this device will be announced the day after tomorrow. I wish Wednesday would hurry up and get here!

Friday, November 6, 2009

Weird Blank Badge Showed Up on My Phone

Nothing earth-shaking here, but notice the badge on my green Phone app button (at the bottom). There is nothing in it!

No! I didn't use Photoshop and remove the number! It did go away later and get replaced with a '1'.

Tuesday, October 27, 2009

Christmas in October: Apple has Some Great Prices

Last night I went to the nearest Apple store. The main reasons I had were to get a copy of Snow Leopard for my iMac, and to find out how to get some network information on said iMac at the Genius Bar.

While I was waiting for my turn at the Genius Bar, I was browsing around the store and noticed the prices of Apple products. Most stuff that's in the news I've read focuses around all the new features of product X or Y, but I haven't seen much talking about pricing.

I happened to glance over at a copy of Final Cut Express on the shelf and looked at the price. $199? First thought was: "No. That can't be right." Next thought was, "This must be an upgrade copy." No it wasn't. I was amazed. Just for grins I checked out the price for Final Cut Studio. About a year ago I bought Final Cut Express which was kind of pushing my budget, and back then when I looked at the price of Final Cut Studio (the full blown used by movie studio version), the price was in the stratosphere! Way way out of my league!

But here I was looking at a price of $999. Not super cheap true. But compared to what it used to cost, amazing! What did it used to cost before when I had checked? More than what I paid for Final Cut Express that's for sure! It's been awhile but I'm pretty sure it was over $8,000. More like close to $10,000. I remember how not in my ball-park the price was that I am sure of!

Other things I noticed: MacBooks (not Pro) were $999 . And MacBook Pros way less than they used to cost with more features than before. Apple has had a reputation for having computers that are more expensive than PCs. This reputation just might be coming to an end.

iLife used to be $99, and iWorks was $99 dollars as well. But they had this nifty package that included the latest version of iLife and iWorks and Snow Leopard for $169. Sweet!

So, I ended up leaving the store with the iWorks/iLife/Snow Leopard box set, Final Cut Studio, a small cable from "Monster" allowing me to plug my iPhone into my car's stereo system, and a big kid-like smile on my face! It was the best Christmas ever! Oh wait! It's not actually Christmas is it. LOL. I think this holiday season Apple is gonna sell allot of stuff and gain even more market share.

Friday, October 23, 2009

Google Search for "iPhone Obsessed"

Alright, at the time of this post my iPhone Obsessed blog is a small fish in a big pond. But hey! There is some increased interest in the iPhone Obsessed!
Check out the Google Insight chart below:

Move your mouse over different points to see the resulting number of searches.

Tuesday, October 20, 2009

iPhone Tech Talk World Tour 2009 is Coming

This free event has Apple technology evangelists coming to various cities giving advice on how to use various technologies in your iPhone Apps. Note: these Tech Talks are only available to developers who are in the iPhone Developer Program. The Tech Talks are in North America, Europe, and Asia. Sadly, there is no Tech Talk in Chicago this year. Bummer!

In North America the following cities will be visited:
  • San Jose - October 29
  • Seattle - November 2
  • New York - December 1
  • Toronto - December 3

Friday, October 16, 2009

Apple Now Offering In App Purchasing for Free Apps

On October 15th, Apple announced that they are giving developers of apps for the iPhone the ability to add in-app purchasing functionality to free apps. This is great news for developers and really the consumer too because it makes it possible that if you have a Lite (free) version of your app and a full (paid) version of your app, now you can have just one app to place on the app store that handles both scenarios.

Imagine a user can download the lite version for free. Try out the app. And, if they like it, purchase the full app inside. Shazam! The lite version of the app instantly transforms into the full version of the app without having to download any new app from the App Store!

And, of course, there is the possibility of doing up-grade purchase in app, subscriptions, etc.

Monday, October 5, 2009

Frustrated With iPhone Provisioning

Above is just a little video rant recorded on my web cam where I vent a little bit about my frustrations in trying to do app provisioning on my iPhone.

Wednesday, September 30, 2009

Favorite Time-Wasting Game: Fieldrunners!

I've meant to write about this tower-defence game... but I guess I have been too busy playing it! The graphics for it are really spiffy, the basic game play is simple to pick up, but as the game progresses it gets brutally challenging!

Basically, you have to stop these little guys, tanks, robots, planes and helicopters from getting from one side of the screen safely to the other side. You build "towers" that deter and shoot at the field runners trying to cross the field (there are 3 different maps at this time).

Certain units are tougher than others, and, as the game goes on, each of the different units becomes progressively tougher. Units have to travel around towers that block them. Except for the copters that is, which can fly in a straight line from one side of the screen to the other. These guys are the bane of Fieldrunners fans!

You have 20 lives. Use up the 20, and the game is over. Great game! They also have a great web site... http://fieldrunners.com/, and, the game will soon be available for the PSP.

About the screen shot:
Yes, it is true, the score in the screen shot above (1,012,075) is accurate and is my score. No cheating was involved. And it is my best score. Mear moments after this screen shot was taken, due to the imfamous copters, the game was over!

Today In iPhone - Now a Favorite Podcast

I was browsing podcasts in iTunes with the subject of iPhone and I subscribed to this podcast.
I subscribed, but I didn't bother listening to it for awhile. Now that I have listened to a couple of episode, I've gotta say that of all the podcasts on the iPhone, I think this one is the best.
I like the user feedback via the voicemail, the news, the show notes/links, etc. I think it is pretty thorough. I've added RSS feed links to the latest podcasts on the right-hand side of the page of this blog.
Two links to get to the the show links, etc. are as follows:

Wednesday, August 26, 2009

Integrated Social Media Tool For the iPhone?

More and more, I'm getting closer to finishing my first iPhone app, which, hopefully, will find its way into the App Store. As I get more and more adept at using the iPhone SDK, I'm beginning to wonder what other apps I could build. The two current apps I'm building I'm keeping it secret what they're for, but there is one idea I am going to put out there before I've written a line of code...

What About an Integrated Social Media Tool For the iPhone?
Currently there is a Facebook app, various Twitter apps, etc.,etc.,etc! Robert Scoble spends allot of time talking about trying to integrate all his data, to integrate all his feeds, etc.

If this could be done on the iPhone, how would you do it? I mean, we don't want some kludgy monstrosity here!

Would the tool just be a way of dispersing our own data quickly to multiple channels? Or would it also include a way of keeping track of all your favorite feeds possibly in real-time?

Give me some feedback people! I'm keen to hear what you have to say! And Robert, if you read this, tell me, what would your social media dream app look like running on the iPhone?

Tuesday, August 11, 2009

Clarification on beginUpdates and endUpdates methods

As I was doing some studying regarding different aspects of working with a UITableView, I came across some information about beginUpdates and endUpdates, which, I hope to share with you to clarify how these guys actually work!

The SDK gives you several methods (of your table view) you can call to animate the addition and deletion of rows/sections on your table:

Animating the adding of a row:
-(void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation *)animation;

Deleting of a row:
-(void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation *)animation;

Adding a section:
-(void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation *)animation;

Deleting a section:
-(void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation *)animation;

Calling a combination of these to say add a row in one spot and delete another row in another spot will generate two different animations in the order that you specified them.

To make things look better, there is beginUpdates and endUpdates. The beginUpdates and endUpdates is basically like a two-phased commit you do on a database... only for animation! If you wrap your sequence of adds/deletes with these guys it will animate the deletions and inserts all as one orchestrated animation! Giving you that professional polished look!

I found some interesting table view code you may want to look at out on the web that uses allot of this. NOTE: I haven't actually tested this code yet so I don't know how well it will actually work.

Monday, August 10, 2009

Some Sort of Auto-Caching of Views

In the iPhone App that I am currently working on, I've got a nice (i) button in the lower right hand corner of each regular view of my application. Tapping on that button causes an info screen to flip into view as one might expect for an App. Basically providing a splash screen including showing the user the current version of the app and a link to the app's web site.

The crazy thing is, that when you tap on the button for the first time during the run of the app (at least in most cases), there is a slight delay and the view appears: BAM! And the nice flip animation either only partially appears or does not appear at all. If it does appear, it kind of shudders in an unprofessional way.

This problem isn't a deal-breaker per-say. I mean, the info screen does come up. No exceptions are generated. And, if you tap on an info button after that during the same run, the animation shows up just fine. It just doesn't have that consistent professional look that I think it should have.

My best guess is that there is some caching of view data, or view controller data going on and something asyncronous going on, so, that it brings up the view the first time before the animation gets a chance to completely run. Of course it is a guess.

Right now, I have separate code in each view controller that happens when the user taps the (i) info button that instantiates an object from the infoViewController class, sets the animation, and calls the proper method to bring up a modal view.

I am thinking now of doing this in my root view controller (with the exception of calling the method to bring it up, assign it to a property, and just call the modal view method whenever I need to. I'm abit lazy, so we shall see if I get to it. My guess is that doing it would make sure that when the user taps on the (i) button the first time and every time afterwards, the info screen will always animate nicely.

Have you run into anything like this?

Thursday, August 6, 2009

Pause/Play clicker on iPhone Headset Wire

You probably already know this, but I share it anyways...
Have you ever been listening to your tunes on your iPhone through the ear buds that came with the phone, and you squeezed the little clicker on the wire to pause the playing of your music, and the music continued playing merrily along?

You clicked it again, and still it played on?

I discovered today, that it is possible to have your headset plugged in far enough to hear your music just fine, but not far enough for the "clicker" to work.

Solution? Just push the plug in a little farther and try again!

Tuesday, July 28, 2009

Comment Posting on iPhone Obsessed Fixed Up

Today I discovered that I had a form of comment moderation turned on on the blog without knowing it. And, as a result, I never went to the moderation page to check out posted comments, and no comments anyone posted showed up on the blog! Bummer!

I now have moderated all the previous posts.

I tweeked the settings today and that should not be a problem anymore. Please feel free to comment on my posts. Ask questions, and I'll see if I can answer them.

Monday, July 27, 2009

Code Journal: Edit Mode on Table Views

I mentioned how my code worked for Edit mode on a table view in my iPhone app using the iPhone SDK 2.0 but then stopped working when I upgraded to 3.0. And I mentioned that after looking into things, it was amazing that my code worked at all the way I had it. Well, now I am going to explain the details.

It all has to do with the tableview methods beginUpdates and endUpdates. Based on the code that I originally used to base my code on, it appeared that beginUpdates was something you called when you entered the edit mode, and endUpdates was something you called when you exited edit mode. Nothing could be further from the truth!

Basically, these methods have something to do with animation of the cells on the table view. You want to do the beginUpdates, move into the table view's edit mode then call the endUpdates right away. Then you want to do the same thing when exit the table view's edit mode.

Below is a screen shot where I am checking the status of an Edit button on my view to toggle the edit mode on my table view:

You will notice how my beginUpdates and endUpdates lines are before and after each setEditing: animated: method.

Hope this helps

Friday, July 10, 2009

Code Journal

I have been back to successfully doing builds of my app on the device for a couple weeks now. One thing I ran into since upgrading to the iPhone 3.0 SDK is that my code which worked before to delete rows in a table view no longer worked.

Last night, after watching a video on table views from the last WWDC, I figured out what I was doing wrong. The issue wasn't really why it stopped working in 3.0, the real issue is how it had ever worked at all in 2.0!

I made some changes to my delete code last night, and it is working once again.
I'll share what I learned in another post later on.

Monday, June 15, 2009

Another iPhone Obsessed Person

Are you obsessed with the iPhone? Julie Blair is. At least in regards to taking pictures with her iPhone.

Check out her post here.

Friday, May 15, 2009

A Look at sketchinz

Sketchinz (http://www.sketchinz.com/), is a nifty little program for the iPhone or iPod Touch that allows you to draw pictures "free-hand." I drew the picture of the rabbit on the left.

Before you think that I'm such a great artist, there is an option to pull up a photo from your photo album that you can essentially trace (which is what I did).

Instead of using your finger to draw as you might assume (as I did), you tilt the phone to move this cross-hair like cursor around on the screen. You pick the current color to draw in and the current brush. Want to move somewhere else without drawing a line? Just pick the brush at the end (which is basically no brush)!

The colors are limited. You only have one hour to draw a picture (which sounds like a lot but if you are really trying to do something it goes by in a flash).

You can save your pictures, but it doesn't save them to your photo album. You can upload your creations to their server so others can enjoy them. They seem to have some sort of drawing contest always going which is cool.

One neat thing it can do is re-draw the picture just like you did it. It sort of has an animated quality to it.

It is a bit limiting but I still think it's worth the price. I find it fun to play with. Price when I got it: $1.99

Tuesday, April 7, 2009

Trying to Feed the Beast

Someone has created a Wordpress blog under the domain http://iphoneobsessed.com/.

They have like one actual new entry in their blog (started about 3 months ago), and the initial post that Wordpress puts in a new blog is still there! I think the owner's will find out that feeding the beast is more about actually finding the time to write stuff and post it on their blog.

BTW, this new site is not my site, and the blog you have before you right now is the original iPhone Obsessed blog. I guess I'm possessive obsessive compulsive!

Thursday, March 19, 2009

iPhone OS 3.0 - Some Thoughts on This Cool Announcement

OS Version 3.0
When I heard that Apple was going to announce some new features in version 3.0 of the iPhone OS, I had some expectations of possibilities like cut and paste. But really, I was blown away by all the goodies that Apple announced Tuesday, as well as by discoveries folks have been making when digging into the new Beta that is now available to developers.
Consumer: Cut and Paste
This functionality has been on other smart phones for a long time. People have complained that it wasn't in version 1.0 of the phone. Well, it's here now. Or will be once 3.0 is moved into production down the road. Honestly, I can understand why this wasn't in 1.0 though, Apple's touch interface is completely different than the other smart phones out there and figuring out a elegant solution that works without junking up the UI is no little thing. I am looking forward to using this feature.
Consumer: New Search Features
Nifty way to search your whole iPhone: Spotlight Searching will be in 3.0 as well as searching in email. I actually could have used the email search a couple days ago!
Linking With External Devices
How cool is it that a glucose meter can link in with an iPhone and feed data into a Diabetes app's database (screenshot below). Hmmm. Think the the possibilities of other devices that could do the same thing... Barcode readers, mini weather stations, my mind is going blank on this right now but I'm sure there are allot of imaginative uses here!

Stuff for the iPhone Developer
In the near-term, I think the iPhone developer really made out like a bandit this release. Apple has put in allot of new functionality in that will give developers allot of abilities that they've been asking for. Some of the features that I am looking forward to using as a developer are:
  • The ability to send email without the user leaving my app.
  • The push ability. Where my user can get notifications without my app being actually open.
  • The internal buy functionality that lets users buy stuff from within the app instead of having to go to the App store.

Below, the Sims game demoed allows you to buy add-ons for the game directly in the game:

Other nifty stuff includes being able to use blue tooth with other iPhone users close by. This could be used for game parties, exchanging business cards, exchanging app info. The imagination runs wild!
Discovered: Tethering
Someone has found tethering in 3.0 (see screenshot below). Yes you could use your iPhone as gateway to the internet for your laptop while on the road. Since phone companies sell cards to do this over cellular networks and charge for bandwidth, and since AT&T gives unlimited data bandwidth for iPhone users, I don't think Apple will just flip the switch on this feature. More likely, they will work it out as a phone company service that you can turn on (for a fee). Just my guess anyway.

I hear that there are hundreds of new features added for developers to take advantage of. I think that though these are not directly consumer features, that down the road they will end up empowering developers to come up with applications that make consumers more and more happy.

Tuesday, February 17, 2009

Creating a Working Nib File With Interface Builder

Interface builder has given me fits. I would do what I think I had to do and BOOM! it would blow up. Other times I would try to do what I thought I should do and it wouldn't let me do it! Well this post is going to be a mini tutorial on how to throw together nib files that actually work with your iPhone project!

Let's stop for a moment and talk about Interface Builder. This program comes with the iPhone SDK. It can be launched from XCode when you double click on a nib (xib) file in your project, or, it can be launched by clicking on a xib file, or by starting it stand-alone. I usually use it from XCode since this is where I'm doing most of my work.

What Exactly is Interface Builder?
This program has been around awhile and is used to design user interfaces. It allows developers/designers to layout their user interfaces in a drag-and-drop visual format instead of having to construct the whole interface using code. This can greatly speed up the development process, and, it can make it possible for non-developers who are designers to be able to do their work. Its been used to design window layouts for Mac applications for quite some time. Apple engineers have now made it possible to design iPhone GUIs on it as well!

Steps... Although you don't have to do things precisely the way I am, I recommend you follow these steps in the same order:

  • Before creating your nib file in Interface Builder, create the View Controller sub-class you want to use with it. Highlight "Classes" in your project's tree view, and create a new class based on UIViewController. You might name it something like "InvoiceViewController".

  • Now, click on "Resources" in you project's tree view and create a new nib (xib) file... use the View xib template! You might name it something like: "InvoiceView". Remember that your nib file basically is going to contain a view for your app with all its various controls.

  • In your code, you are going to create an instance of an object from your view controller class. This object will "control" your view. Inside of this object will be a "view" object. For your code and nib file to work together properly, you need to link up the view object in your view controller to the View inside of your nib file. The next few steps tell you how.

  • Double click on your new nib file in your XCode Project. It will open up in Interface Builder.

  • Bring up the Document window if its not showing already. It basically looks something like the window on the right in the screen shot at the top of this post. It may look a little different depending on which view mode is being used.

  • Don't put any controls/tables/sub-views on the view until later (we'll tell you when).

  • Click on the "File Owner" Icon. If the window wasn't highlighted to begin with, you may have to click on it again to actually select it.

  • Make sure that the "Attributes" window is showing and pick the (i) tab.

  • There will be a class name to select for the File Owner to be. The default is NSObject. Not very useful! Change it to the name of your view controller class. In our example, we would put "InvoiceViewController". If we didn't do this, Interface Builder (IB) would not know how to hook up its View to your view controller's view! File Owner is the name of the class that is going to "own" or "control" this nib.

  • Now, make sure "File Owner" is still selected and, on the Attributes window, you will see a tab that looks like a little white arrow pointing to the right on a bright blue circle. Click it.
  • You will see all the events and objects that the File Owner (your view controller class) supports. One of them will be view.

  • There will be a little circle outlined in black to the right of it. Click it, hold down your mouse and drag the line that appears to either the View icon in the Document window or the View window. It will highlight, when it does, release your mouse. You will see that a linkage has been created.

  • Save your work.

  • Note that at this point, it is okay to add your sub views/tables/controls.

Now if you use this new nib file in your project, it should not blow up on you. Note that I have not covered capturing events in this mini tutorial, or setting label values programatically, etc. This is just covering setting up a nib file so that it will load properly in your iPhone project.

Hope this helps!

Monday, February 16, 2009

Going Again Full Bore

After I had submitted my issues on-line for the program portal, I just kept plugging away at my iPhone application. I must say that my coding proficiency is really kicking in now! I was just limited to testing in the simulator.
Well, was it two or three days ago?... I logged into the portal to see if the status of things had changed. I was bracing myself to see the same-ol' same-ol'. But there was an "Approve" button there! I clicked it and got a nice download link.

Later that Night:
I finally had the time to download the certificate to my iMac. I went through the proper hoops and shazam! It worked! I can now run my apps on my actual iPhone again!

Wednesday, February 11, 2009

2.2 and Program Portal Woes

I made (in my opinion) a big mistake by installing iPhone OS 2.2 on my iPhone a couple of days ago. Now I cannot install any apps I've worked on onto my phone! :(

I basically thought, well, it doesn't matter that this happened, I just got an iMac a short time ago and I want do do development on it instead of my MacBook anyway. The screen is much larger and easier to read that the laptop, the keyboard is better, it has more storage, etc.

So I revoked my certificates, created a request for a certificate and posted it into the program portal.

Part of vast frustration: After posting, usually I get the option to approve the certificate (since I am the "agent") but no option shows up to do this. Arrrrggghhh!

I've submitted a "request" I think the day before yesterday. Still no word from Apple. It makes me want to tear my hair out! Appeo! Appeo! wherefore art thou Appeo!

Another wonky thing: Controls you place on a view in Interface builder don't always appear in the simulator where you put them in the builder. You have to offset their positions to make them come up right. Also, the positioning (both wrong) is different from 2.1 to 2.2! 

If you haven't installed the iPhone OS 2.2 on your iPhone yet, I would say hold off for now. Just my take.

Wednesday, January 28, 2009

A New Dawn?

Quite some time has passed. In that period of time much has transpired.
  • I have a better understanding of Interface Builder now (I would not say that I have a good understanding yet... but I know enough to get some stuff done now).
  • I've actually got little apps I've made to install and run on my actual phone instead of just running in the iPhone Simulator.
  • I've finally got a tab view/navigation view controller type app to work properly.
  • I've got more proficient at working with "tables" in the views (not to be confused with database tables).
  • And speaking of databases, I've been able to create an app the creates a SQLite database file and creates some tables in it and read/writes data to those tables.
  • I've successfully got to work the showing and hiding of a modal view with a modal view controller.
  • Oh, and I bought myself a new iMac for my birthday!

I wouldn't say that I have learned everything I need to know in order to write successful iPhone apps, but I think I probably have 90% of what I need to know down. I am planning on doing some video tutorials on what I've learned... stay tuned...