Sponsors

 
Showing posts with label iPhone Development. Show all posts
Showing posts with label iPhone Development. Show all posts

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.



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.

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?

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.

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...

Tuesday, December 9, 2008

Digging into iPhone Programming: Some Books to Check Out

With Apple's NDA out in force. It was very frustrating to find any information outside of Apple's online documentation on developing software for the iPhone. You want to take classes? Sorry! Apple is great at having all sorts of classes on various Apple software at their stores. Not for programming the iPhone though. What about classes offered by someone else? Sorry! Websites? Books? Buzzzzzz! No dice. Thankfully the super-restrictive NDA has been lifted (of course if you follow iPhone programming development you already know that)!

There are three books that I have had my nose stuck in of late. Let's take a high-level look at each:

Programming in Objective-C
Initially, I got this book pre-NDA. I mean, Objective-C is not just a language for programming on the iPhone or the iPod Touch. It's been around for years. It is the main programming language Apple uses for their apps that run on the Mac.

Considering I had never programmed in Objective-C before much less heard of the language in the first place, this seemed like a good book for me to get.

Turns out this is a pretty good book. It won't actually show you development on an iPhone, but it will teach you Objective-C. It assumes zero knowledge of the language (which is good because that is where I was at)! It allowed me to start to get used to Objective-C's strange syntax of square brackets, declaring object references with asterisks, an initial foray into delegates and more. Don't know Objective-C? Get this book!

Once the NDA was lifted, the following two books became available for purchase:

Beginning iPhone Development: Exploring the iPhone SDK
Of the three books mentioned here, this book is my favorite and the one I have been spending most of my time with. It has spent allot of time with me going to and from work on the train. I've been reading it after dinner. I've been sitting with it and my Mac Book trying stuff out in XCode. It has been my evening reading before going to sleep. It's really a good book.

There are some things I wish were covered in more detail. I wish there was more info on tab view controllers and just more conceptual information on view controllers period. I find it hard to visualize some of the view controller/view relationships.

That being said, the book is chock full of detailed examples. The authors take you step-by-step through each example in a very thorough manner. I love the cheerful banter of the language. It's just fun reading this book! The layout of the book, the illustrations, are well done. I just want to pick it up to look at it. Does that mean I'm a geek? :P

One thing I would mention though, if you never programmed in Objective-C before, this book is not enough. There are syntax things going on that you'll be saying, "what is that for?" Best to get Programming in Objective-C to go along with it.



The iPhone Developer's Cookbook
I actually got this book before Beginning iPhone Development. It is instructional and can help you learn how to program the iPhone, but, just has the title implies it's more of a cookbook type of book. That is, it has "recipes" on how to code different things on the iPhone.

The section on view controllers was helpful to go along with what was said in the Beginning iPhone Development book. It didn't complete the picture for me though.

One thing I like about this book is the recipes included for functionality that does not necessarily show up in Apple's documentation. Like do you want your app to use that cool feature known as Cover Flow? This book has a recipe on how to do it.

Again, if you don't know Objective-C, you best get a book like Programming in Objective-C to go along with it.

Final Thoughts on These Books
If you're looking for information on how to use the Program Portal after paying your $99, you won't find much here. What you will find is a lot of good programming information to kick-start you into the world of iPhone/iPod Touch software development.