Archive for 'Programming'

Tips: UITableView

Here’s a selection of UITableView advice and code for you:

Easy custom UITableView drawing

Customizing your UITableView can be really easy. You don’t need custom drawing code. You don’t need subclasses of anything. Cocoa Touch provides all the drawing capability you need, all you have to do is use the right classes in the right ways and provide the layout.

Fast Scrolling in Tweetie with UITableView

Scrolling is the primary method of interaction on the iPhone. It has to be fast. It has to be fast. More than a few developers have asked me how I do it in Tweetie, so I figured I would share a really fast and really clean technique people can adopt in their own apps.

ASKit from Enormego’s open source

ASKit is an easy to use library for your iPhone applications. ASKit provides AppStore styled table views

UITables with Downloaded Images – Easy Asynchronous Code


Multi-threaded programming is hard and should be avoided whenever possible, and in this case Cocoa’s beautiful design came to my rescue: UIView heirachy + URL loading system + delegate design = multi-threaded image loading with no multi-threaded coding!

Drill down table view with a detail view


Using a drill down table view we can display hierarchical data where the last view is responsible of displaying some detail information. This view in which the detail information is displayed can be the same for all the data in the table view (like my last tutorial) or it can be different based on the path that the user took. In this tutorial I will show you how to add a different detail view based on the path the user took to get to the last item …

Lots of good stuff there, enjoy!

[EDIT: Check out ABTableViewCell, in Fast Scrolling in Tweetie with UITableView!]

Continue Reading →
1

Tip: Crash Reports

OK, maybe it doesn’t quite count as a “tip” exactly to tell you to read an Apple tech note, specifically

Technical Note TN2151
Crash Reporting for iPhone OS Applications

… but just in case you haven’t stumbled across it so far, there’s a particular point that you need to be aware of before you submit your next iPhone application build to Apple, which we figure pushes this into the tip-worthy category:

…Unlike crash logs from Mac OS X, iPhone OS logs do not contain symbol information when they’re written out. You have to “symbolicate” iPhone OS logs before you can analyze them.

Symbolication – resolving stack trace addresses to source code methods and lines – requires the application binary that was uploaded to the App Store and the .dSYM file that was generated when that binary was built. This must be an exact match – otherwise, the report cannot be symbolicated. It’s essential that you keep each build distributed to any users (regardless of mechanism) with its .dSYM file.

IMPORTANT: You must keep both the application binary and the .dSYM file in order to be able to fully symbolicate crash reports. You should archive these files for every build that you submit to iTunes Connect. The .dSYM and application binary are specifically tied together on a per-build-basis, and subsequent builds, even from the same source files, will not interoperate with files from other builds.

Given a crash report, the matching binary, and its .dSYM file, symbolication is relatively easy…

Now you know!

Continue Reading →
3

Resources: Open Source

Let’s list off today some sites worth checking out for iPhone/Mac programming open source goodies should there not — heaven forfend! — be anything particularly appropriate already mentioned in the annals of this humble journal. Hard though that is to imagine of course!

And for a vast list of iPhone-devoted not only open source projects but everything from LinkedIn groups to useful blogs (why, it even lists us! How sweet!), the pithily named

iPhone Resources

is not to be missed.

As always, if there’s anything noteworthy we’ve missed, comment away!

Continue Reading →
6

Resources: Chipmunk

So a while back we rounded up resources for the Cocos2d sprite library, and a fine library it has turned out to be too; now we’re getting into figuring out the Chipmunk physics library that it comes with, and that deserves its own resources post. It’s a bit slim, so if you have more to add, please do. But for now:

First off, the project home page for videos, tutorials, and the latest links.

Currently the source is hosted at Google Code.

Start out reading with the official documentation and the repository wiki.

Excellent tutorial to follow through next here.

And when you have more questions, the nicely active development boards are here!

UPDATE:

The Chipmunk SpaceManager is a helper for cocos2d; source on Google Code.

The Chipmunk author has an Objective-C binding for sale, at $199.

VertexHelper is a tool for graphically defining Chipmunk or Box2D sprite vertices.

Continue Reading →
2

Code: AQXMLParser

Got a big (like, 22 MB) XML file to parse on the iPhone? Want to reduce the memory usage from NSXMLParser’s huge (like, 123 MB) virtual memory usage by several orders of magnitude down to almost nothing (like, 68 kb)?

Yeah, we thought you did.

The magic trick is to use “Alan Quatermain”s AQXMLMemoryParser:

Here’s the output. I think it shows that AQXMLParser is going to be *lovely* for the iPhone. Mwa-ha-haa.

Testing NSXMLParser from URL...
Parsed 200000 numbers
Peak VM usage: 128991232 bytes

Testing NSXMLParser with mapped data...
Parsed 200000 numbers
Peak VM usage: 130035712 bytes

Testing AQXMLParser...
Parsed 200000 numbers
Peak VM usage: 69632 bytes

That’s right, the NSXMLParser variant (calling xmlParseChunk() with all data at once) uses 123-124MB, while AQXMLParser (calling xmlParseChunk() with 1KB at a time, not loading all data anywhere) gets 68KB.

In short: AQXMLParser == T3h w1n!

Indeed. Source is in AQToolKit on github which is just full of all sorts of other useful goodies as well. Note also author’s blog for background.

h/t: iPhone Development!

UPDATE:

Check out parsing example here. As referred by this chuckle-worthy post.

Continue Reading →
0

Source: Bickboxx

Here’s another open source project for the iPhone that may catch your interest: the available-on-the-App-Store Bickboxx is open sourced on github:

Our vision with Bickboxx is to build a community of developers for source code sharing, discussion about building iPhone applications, and resource sharing.

When you go to build your first iPhone app or your 100th…you have a great resource to start with Bickboxx.

We’ll be adding more and more features to Bickboxx and committing them to the github.com repository…

We’ll also be posting more tutorials about how we added these features to TheAppleBlog.com. So feel free to kick back, grab a fork (pun intended) and contribute some great open source code!

My, they’re bright-eyed fellows over there, aren’t they? Always amusing, er we mean inspiring, to see such sparkly enthusiasm, indeed.

Continue Reading →
0

NimbleKit

Here’s something that our web programming friends will probably find of intense interest, and real programmers (we kid, we kid) may be mildly curious about as well: it’s called NimbleKit, and it’s … well, let’s let them describe themselves:

NimbleKit is the fastest way to create applications for iPhone and iPod touch.
You don’t need to know Objective-C or iPhone SDK.
All you need is to know how to write an HTML page with Javascript code.

They do claim to have some fairly comprehensive  feature support,

  • Native iPhone interface elements
  • Full control of application appearance
  • Play bundle audio files
  • Play audio streams from the Internet
  • Support iPhone vibration
  • Support Address Book with full search and people picker
  • Access to bundled files
  • Check Internet availability
  • Location services (GPS)
  • Access to images (take photo or browse in library)
  • And much more…

Indeed. We’re not quite intrigued enough at the moment to bother downloading it ourselves, but hey if you are, be sure and let us know what you think!

Continue Reading →
0

Snippet: Data Sharing

Now here’s a snippet which will probably be a surprise to you: How to write a file to be shared between applications from within your sandbox! Yes, we said “from within your sandbox”. No, really, we did. And simple once you know how, of course — here it is:

BOOL result = [@"malc" writeToFile:@"/private/var/mobile/Media/DCIM/
malc.txt" atomically:YES];

Why does that magic incantantion work? Well, if you’re a particularly clever spark, it occurred to you that

I discovered this when I realised that the UIImagePickerController writes camera photos to that folder too, so your app must have write access, which it does :-)

Yes, when you think about it, indeed it must, mustn’t it now? And whilst I’m quite sure from Apple’s perspective this counts as unsupported, at first glance it doesn’t appear to be actually illegal by any currently published standards … so assuming that you put in appropriate writability verification in case the picker’s path changes or they get pickier (heh) about allowing access in future, this seems like a most excellent way to approach the problem of application data transfer/sharing on the device!

h/t: iphonesdk!

Continue Reading →
4

Snippets: Generic Controllers

Over at iPhone Development they’ve  been writing a series of articles describing a variety of handy controller classes:

Source for the first four is handily available here. Enjoy!

Continue Reading →
1

Source: Networking

This looks like an excellent tutorial on implementing Bonjour-based networking in your iPhone application, and of course there’s source code provided. Yes, most direct applications of this will probably be more appropriately addressed with GameKit.framework in OS 3.0 — but it certainly can’t hurt to supplement Bluetooth local networking with WiFi local networking … or, of course, offer both! Also note that the author offers ByteClub, a paid multiplayer gaming platform.

And in order to do that, an excellent place to look is MYNetwork the Mooseyard Networking Library from the redoubtable Jens Alfke … who has his own commentary on the above tutorial, and has even forked the above source to use MYNetwork. For any networking needs past GameKit only, that’s definitely where we’d start!

[UPDATE: And speaking of GameKit … there’s a pre-WWDC release of a contact sharing application and full source code here!]

Continue Reading →
1
Page 79 of 97 «...5060707778798081...»