iPhone
The Right Way to Load a Custom UITableCellView
13/11/10 08:50
Although there are lots of places online to get iOS programming tips, the quality of the information at most places is really pretty low.
For example, I needed to load up a custom UITableCellView from a xib created with Interface Builder. If you poke around online, you'll see several examples that involve loading the xib manually and walking down the object graph until you find a specific class. Fragile, brutish, and totally unnecessary.
The correct way is crazy simple. The xib loader is already expecting to hookup the object graph to the "owner" object (represented by the File's Owner in Interface Builder. If you only use the custom cell in one controller, just expose an IBOutlet for it's class, set your controller as the File's Owner class type, and wire it up in IB.
Let's assume your custom cell class is called MyCustomTableCellView and your controller that needs it is called MyCustomTableViewController. In the controller's header, add a property like this:
@interface MyCustomTableViewController : UITableViewController {
MyCustomTableCellView *customCell;
}
@property (nonatomic, assign) IBOutlet MyCustomTableCellView *customCell;
@end
Notice I'm using "assign" instead of "retain" because I don't want the controller to take ownership of the cell, just hold on to is momentarily so that the tableview can take it.
Synthesize the property and then when you need a new instance of MyCustomTableCellView from the xib, use this code:
[[NSBundle mainBundle] loadNibNamed:@"MyCustomTableCellView" owner:self options:nil];
cell = customCell;
Viola, custom cell view loaded painlessly.
For example, I needed to load up a custom UITableCellView from a xib created with Interface Builder. If you poke around online, you'll see several examples that involve loading the xib manually and walking down the object graph until you find a specific class. Fragile, brutish, and totally unnecessary.
The correct way is crazy simple. The xib loader is already expecting to hookup the object graph to the "owner" object (represented by the File's Owner in Interface Builder. If you only use the custom cell in one controller, just expose an IBOutlet for it's class, set your controller as the File's Owner class type, and wire it up in IB.
Let's assume your custom cell class is called MyCustomTableCellView and your controller that needs it is called MyCustomTableViewController. In the controller's header, add a property like this:
@interface MyCustomTableViewController : UITableViewController {
MyCustomTableCellView *customCell;
}
@property (nonatomic, assign) IBOutlet MyCustomTableCellView *customCell;
@end
Notice I'm using "assign" instead of "retain" because I don't want the controller to take ownership of the cell, just hold on to is momentarily so that the tableview can take it.
Synthesize the property and then when you need a new instance of MyCustomTableCellView from the xib, use this code:
[[NSBundle mainBundle] loadNibNamed:@"MyCustomTableCellView" owner:self options:nil];
cell = customCell;
Viola, custom cell view loaded painlessly.
Approved!
26/07/10 20:12
Well, it took about six months to develop (really only about two week spread out over a ton of weekends with an hour here and an hour there) and almost exactly ten days to review and approve, but my first iPhone app, The Fox & The Grapes, is up for sale in the iTunes store.
I have no idea if it will even make back the cost to develop it, which wasn't all that much really. It was a lot of fun to develop and I'm certain I'll do more apps for the iOS platform (iPhone/iPad/iPod Touch) and probably for Mac OS X, too, since it's very similar.
Writing software is way too much fun.
I have no idea if it will even make back the cost to develop it, which wasn't all that much really. It was a lot of fun to develop and I'm certain I'll do more apps for the iOS platform (iPhone/iPad/iPod Touch) and probably for Mac OS X, too, since it's very similar.
Writing software is way too much fun.
My First iPhone App Store Submision
18/07/10 10:09
Yesterday was the big day; I submitted The Fox & The Grapes to the Apple App Store. Not really sure what to expect, but I hope some people find it and enjoy it.
I updated the web page a little, but I have to say I’m not 100% happy with it. I still think it’s a little wordy, but I think it’s OK for now.
Next up is a new version that supports the iPad.
I updated the web page a little, but I have to say I’m not 100% happy with it. I still think it’s a little wordy, but I think it’s OK for now.
Next up is a new version that supports the iPad.
Code Complete!
11/07/10 21:25
Yeah! My iPhone app is feature complete and just about ready for submission to the store. A little bit more testing and she’ll be App Store bound.
Spent a few hours today getting the layout and artwork together for the app’s web page. Man, that’s a lot of work!
Spent a few hours today getting the layout and artwork together for the app’s web page. Man, that’s a lot of work!
How Ubuntu Taught Me Not To Fear The App Store
01/07/10 07:10
There’s quite an uproar in parts of the tech community advocating the Android platform over the iOS (iPhone/iPad) platform because Android is “open” and iOS is “closed”. Frankly, I think this idea is misguided. In addition, I believe companies like Google are cynically furthering this misunderstanding in an attempt to manipulate the tech community for PR purposes. I also think this is detrimental to the broader user community and, if successful, a turn we’ll probably regret in the future.
So how could someone who loves open source software and who has contributed to several open source projects take such a counter intuitive position? Shouldn’t I be chanting “Up With Android, Down With iOS?”
Let me tell you why I’m not.
It was Ubuntu that taught me. These days, I won’t recommend any Linux distribution other than Ubuntu to someone who isn’t a unix expert and knows what they’re doing. Even those folks should probably think twice before passing on Ubuntu. Don’t get me wrong; RedHat/Fedora, SUSE, et al are excellent, as are the BSDs. But, Ubuntu has a massive advantage; it’s engineered to be straightforward and simple to use for the majority of use cases and is managed by a community that takes the responsibility to maintain that very seriously.
When you run Ubuntu, the preferred way to get software onto (or off of) it is using the Ubuntu Repository. For GUI users there’s a beautiful app browser that lets you look for applications you might want, see some ratings, and click a button to install if you see something you like. If any updates come out, they’re pushed to you automatically. If you get tired of the app, you can just as easily remove it. This repository is curated; a group of people carefully review anything that goes into the repository to make sure it’s safe, installs cleanly, and so forth before it can be published and signed by Ubuntu. As an Ubuntu user, if you stick with the official repositories, you really don’t have to worry that much about your computer that you’re relying on getting trashed by spyware or malware, your personal data being stolen, your system getting some poorly written piece of crap on that prevents it from shutting down cleanly, running smoothly, or just getting trashed by a half baked app.
Does that mean Ubuntu isn’t “open”? Of course not, it’s fully open in every way that the word “open” can be meaningfully applied to software. What it makes it is “managed” and this is a powerful advantage to the platform in general.
Contrast that with the Windows platform. Even though I can install anything I want onto a Windows machine (and many come with tons of crap preinstalled on them), this doesn’t make Windows an “open” platform. In fact, it’s about as closed as they come. Rather, it makes Windows “unmanaged”. This, to my estimation, is a major failing of the Windows platform and why it is so often the vector for viruses and exploits that have done massive harm to the community at large.
How does this relate to the emerging mobile platforms, Android and iOS? Is iOS really “closed”? Well, it’s based on many open components like BSD, SQLite, WebKit, LLVM/GCC, and hundreds of libraries many of which Apple donates to the open source community and others it activity contributes to. There are open source applications available from the “closed” App Store, like Colloquy. Conversely, Android is also based on similar open components, but like iOS most of the apps that run on it are “closed”. So what’s the difference?
One big difference between the two is that iOS is, like Ubuntu, a managed platform whereas Android is, like Windows, for the most part unmanaged. If you use an iPhone or iPad you can be certain that the primary conduit for installing apps is being managed by a party with a vested interest in keeping is safe, reliable, and reputable. This might mean some hackware isn’t available or you can’t browse to some random site and click the “download” link to install an app, but it does mean that your system is as safe and reliable as you can reasonably expect it to be.
If you do get some app that you want gone, just delete it. You system won’t become littered with half installed bits of broken apps that make it run slowly or cause weird bugs. In a way, your device becomes what us techies call a “production” device. This word has a special meaning in the tech circles because it means a device plays a critical role that someone or something is depending on. It’s locked down from casual modification. New software and updates are applied in a considered manner, and efforts are taken to prevent it from experiencing downtime or sluggish behavior.
After nearly three decades of developing software for and using a computer regularly it’s really sunk in to me that your primary computer is a production device. It needs to be reliable and safe. Downtime or poor performance hurts you. Even having to do mindless and unnecessary maintenance on it (like cleaning out busted uninstalls or worse, wiping it and restoring it) is counterproductive.
Whether accidentally or intentionally, Apple seems to have gotten this resoundingly right with iOS. Google and it’s advocates haven’t figured it out, yet. I hope for the sake of the next generation of computer users, they do.
So how could someone who loves open source software and who has contributed to several open source projects take such a counter intuitive position? Shouldn’t I be chanting “Up With Android, Down With iOS?”
Let me tell you why I’m not.
It was Ubuntu that taught me. These days, I won’t recommend any Linux distribution other than Ubuntu to someone who isn’t a unix expert and knows what they’re doing. Even those folks should probably think twice before passing on Ubuntu. Don’t get me wrong; RedHat/Fedora, SUSE, et al are excellent, as are the BSDs. But, Ubuntu has a massive advantage; it’s engineered to be straightforward and simple to use for the majority of use cases and is managed by a community that takes the responsibility to maintain that very seriously.
When you run Ubuntu, the preferred way to get software onto (or off of) it is using the Ubuntu Repository. For GUI users there’s a beautiful app browser that lets you look for applications you might want, see some ratings, and click a button to install if you see something you like. If any updates come out, they’re pushed to you automatically. If you get tired of the app, you can just as easily remove it. This repository is curated; a group of people carefully review anything that goes into the repository to make sure it’s safe, installs cleanly, and so forth before it can be published and signed by Ubuntu. As an Ubuntu user, if you stick with the official repositories, you really don’t have to worry that much about your computer that you’re relying on getting trashed by spyware or malware, your personal data being stolen, your system getting some poorly written piece of crap on that prevents it from shutting down cleanly, running smoothly, or just getting trashed by a half baked app.
Does that mean Ubuntu isn’t “open”? Of course not, it’s fully open in every way that the word “open” can be meaningfully applied to software. What it makes it is “managed” and this is a powerful advantage to the platform in general.
Contrast that with the Windows platform. Even though I can install anything I want onto a Windows machine (and many come with tons of crap preinstalled on them), this doesn’t make Windows an “open” platform. In fact, it’s about as closed as they come. Rather, it makes Windows “unmanaged”. This, to my estimation, is a major failing of the Windows platform and why it is so often the vector for viruses and exploits that have done massive harm to the community at large.
How does this relate to the emerging mobile platforms, Android and iOS? Is iOS really “closed”? Well, it’s based on many open components like BSD, SQLite, WebKit, LLVM/GCC, and hundreds of libraries many of which Apple donates to the open source community and others it activity contributes to. There are open source applications available from the “closed” App Store, like Colloquy. Conversely, Android is also based on similar open components, but like iOS most of the apps that run on it are “closed”. So what’s the difference?
One big difference between the two is that iOS is, like Ubuntu, a managed platform whereas Android is, like Windows, for the most part unmanaged. If you use an iPhone or iPad you can be certain that the primary conduit for installing apps is being managed by a party with a vested interest in keeping is safe, reliable, and reputable. This might mean some hackware isn’t available or you can’t browse to some random site and click the “download” link to install an app, but it does mean that your system is as safe and reliable as you can reasonably expect it to be.
If you do get some app that you want gone, just delete it. You system won’t become littered with half installed bits of broken apps that make it run slowly or cause weird bugs. In a way, your device becomes what us techies call a “production” device. This word has a special meaning in the tech circles because it means a device plays a critical role that someone or something is depending on. It’s locked down from casual modification. New software and updates are applied in a considered manner, and efforts are taken to prevent it from experiencing downtime or sluggish behavior.
After nearly three decades of developing software for and using a computer regularly it’s really sunk in to me that your primary computer is a production device. It needs to be reliable and safe. Downtime or poor performance hurts you. Even having to do mindless and unnecessary maintenance on it (like cleaning out busted uninstalls or worse, wiping it and restoring it) is counterproductive.
Whether accidentally or intentionally, Apple seems to have gotten this resoundingly right with iOS. Google and it’s advocates haven’t figured it out, yet. I hope for the sake of the next generation of computer users, they do.
App Store, Here We Come!
14/03/10 14:54
Well, it’s no concept-to-app-store-in-one-week hit, but my first commercial iPhone app is getting really close to ready for submission to the app store!
