Posts Tagged 'Programming'


If you want to pass your Objective-C objects across a network connection, this may be worth looking into:

There’s a few problems with Distributed Objects that bug me:

1. Uses exceptions for errors, which just feels unnatural and cumbersome in Cocoa

2. Claims to be capable of more than it really is, such as sending any single ObjC message call over the net (see mikeash’s example regarding -getObjects:range:), and acting like a normal Cocoa object

3. Defaults to synchronous message calls, potentially over the internet(!)

4. It’s guts are not interchangeable, meaning you cannot fiddle with the lower level parts at all

The framework SocketObjC is very similar to Distributed Objects, with a few major differences:

1. All messages are sent asynchronously

2. The underlying message passing system simply uses TCP via AsyncSocket

3. Instead of exceptions, problems are simply ignored (this could easily be fixed by anyone)

4. Messages with return values can handle those returned values using block callbacks, making use of what I later learned is called “Continuation Passing Style”

5. Limited to passing and returning objects that conform to NSCoding

6. Possible to add support for secure TCP message sending (via CFStream/CFSocket, via AsyncSocket)

As you can see there are some trade-offs, for better or worse. But all in all I think this is more useful than DO for passing messages across the internet.

h/t: !

Continue Reading →


Got a need to integrate Flickr support into your iPhone or desktop app? Well, here’s the open source project for you:

ObjectiveFlickr is a Flickr API framework designed for Mac and iPhone apps.

Yes, straightforward enough and you’d probably have googled it yourself if you need it, but we’d like to draw your attention to this interesting idea that might not have occurred to you about how to integrate web pages and iPhone apps:

…iPhone and iPod Touch posed a challenge to the auth model above: Opening up Mobile Safari then ask the forgetful user to come back is a bad idea.

So many iPhone developers have come up with this brilliant idea: Use URL scheme to launch your app. It turns out that Flickr’s web app auth serves the idea well. Here is how it works:

   1. The app prompts user that it’s going to open up browser to ask for permission.

   2. The user taps some “Open” button, and the app closes, Mobile Safari pops up with Flickr’s login (and then app auth) page.

   3. Then magically, Mobile Safari closes, and the app is launched again.

   4. There’s no Step 4.

What’s behind the scene is that the iPhone app in question has registered a URL scheme, for example someapp:// in its Info.plist and the app developer has configured their Flickr API key, so that when the user grants the app permission, Flickr will redirect the web page to that URL the app developer has previously designated. Mobile Safari opens that URL, and then the app is launched…

Well yippee, perhaps you are thinking, now when would I ever care to jump out to Safari and back when I’m writing an app?

Ah, let me tell you when you would care to jump out to Safari and back when you’re writing an app.

You could care to do that if you write an app that loads up a web page to make a donation in a UIWebView, and when you send your shiny new app off to Apple, BRRRRAAAANNGGG it bounces back with

Thank you for submitting [REDACTED] to the App Store. We’ve reviewed [REDACTED] and determined that we cannot post this version of your application to the App Store because it does not adhere to the charitable requirements outlined in the iPhone Developer Program License Agreement …

… Donations are not permitted to be taken within the application, however it is possible to provide a donation link to your web site. This link is required to open Safari to collect the donation. We encourage you to make the necessary changes to your application and resubmit it for review.

Well, the license doesn’t say it has to open in Safari, it just says “a direct link to a page on Your web site”. And that’s exactly what was in the UIWebView, @#($@^#$^!!! it. So we duly complied and resubmitted, but it makes the experience significantly more annoying. But if this clever stratagem had occurred to us, we could have had the opened-in-Safari page open back up the triggering application. That would have made for a happier client!

Continue Reading →

Placing Settings

Here’s an excellent article dissecting, with scads of backing opinions, the pros and cons of putting your settings in as opposed to in your application.

Personally, from observing actual users it seems pretty clear that on the order of 98% of them have absolutely no idea whatsoever that they should look anywhere other than in your app for settings that control your app. Understandably enough. Which makes that decision pretty easy. Still, the reasoning and discussion of appropriate UI here is worth a read.

Bonus: Vector and bitmap icon package for the commonly used “cog” and “info” settings tab bar/toolbar icons!

h/t: NotTooBad!

Continue Reading →

HTML5 Roundup

Here’s a collection of iPhone-targeted HTML5 links we stumbled across recently, for whenever it is you decide to get into writing cross-platform or non-AppStore apps:

Tutorial: Your First Mobile HTML5 App – The Basics, Forms, and Geolocation (Part 1)

Tutorial: Your First Mobile HTML5 App – Offline Storage (Part 2)

Nice and easy introduction.

HTML fullscreen apps for the iPad

Some handy formatting tips.

Create offline Web applications on mobile devices with HTML5

From IBM developerWorks, no less; provides a sample inventory management application, tested on an iPhone 3GS and a Palm Pre.

Opensourcing Golingo

Source of a word puzzle game published in the App Store, created with Titanium Mobile and Web code.


Sprite library using the canvas tag, targeted at retro pixelated games; several playable demos.

Japstore – The free Javascript application store

Bookmarkable Javascript applications and a downloadable SDK to create them.

Parcycle: A Particle System with HTML5 canvas

Oh, we just love those particle systems, yes we do. Browser and offline webapp demos for your hypnotic pleasure. And dig around on the site for other links to various webapp examples.


Learn HTML5: 10 Must Read Lessons has a bunch of good stuff.

Continue Reading →

Tip: Shipping App Size

Just in case you ever need to know in detail:

How to calculate the final size of an iPhone App before approval

but briefly, since your executable is encrypted for the store it’s not going to compress well; so for a rough guess, try

  1. open the .app bundle via right-click -> Show Package Contents (on Mac)
  2. locate the executable file and remember its (uncompressed) size (Size “A”)
  3. delete the executable from the bundle
  4. zip the bundle and remember the bundle’s compressed size (Size “B”)

Size “C” are the 100 KB from the additional files added to the bundle by Apple. The final calculation for the maximum size of your App is as follows:

A + B + C = maximum size of your App after approval

The calculation put in words:

(uncompressed executable size) + (app bundle compressed but without executable) + 0,1 MB = maximum size of your App after approval

Handy to know if you’re butting up against the over the air download limit!

Continue Reading →

5 Ways to Draw a Shape

Unless you’re a really serious CoreGraphics expert, there is almost certainly something to be learned here:

5 ways to draw a 2D shape with a hole in CoreGraphics

In this post, I look at 5 different ways that you can draw a very simple shape: a square with a triangular hole cut out of the center. In a drawing environment like CoreGraphics which offers double buffering, winding count path filling, even-odd path filling and clipping regions, there’s no single answer. An iPhone sample project is provided containing the code but all drawing functions are identical on the Mac…

Continue Reading →


So it’s pretty easy to customize the look of regular table views, pretty much set background to [UIColor clearColor] and you’re done, but no doubt you’ve noticed it’s quite considerably trickier to customize the look and background of grouped tables, specifically getting those @(#&Y$!! corners right. Well, here is UACellBackgroundView to sort that out for you:

How to Make Custom Drawn Gradient Backgrounds in a Grouped UITableView with Core Graphics

that lets you produce pretty gradient cells like this with just a couple lines of code in your regular table handling:


Very nice, very nice. Based on this Stack Overflow question, which you can find more exposition on here; but hey, it only took us a few minutes to toss UACellBackgroundView into our current panic for a nice shininess upgrade — and it’s all about the shiny! — so no need to look further, really.

Continue Reading →

cocos2d + Particle Designer

So that awesome toy^H^H^H development assistant Particle Designer that we mentioned a while back is now officially released and you can download it from its new website — for only $7.99 USD, what a deal we’ve got ours! — and there is a completely unexpected (by us, anyways) feature; it integrates directly with cocos2d.

Yep, cocos2d 0.99.3-rc released today has support for Particle Designer:

In order to use the particles created with it you should:

1. Download & Register Particle Designer (you need to register it in order to save the particles)

2. Use the “cocos2d (plist)” format when saving the texture (you can embed the texture or not. cocos2d supports both format)

To load a particle created with Particle Designer you should do:

// Either you can create a Quad particle system

id particleSystem = [CCQuadParticleSystem particleWithFile:@"MyParticle.plist"];

// …or a Point particle system.

id particleSystem = [CCPointParticleSystem particleWithFile:@"MyParticle.plist"];

cocos2d supports all the Particle Designer features…

It’s just like getting a heaping helping of awesome sauce on your awesome sundae, isn’t it now?

[UPDATE: And now with tutorial video!]

Continue Reading →

CoverFlow Tutorial

Here’s an excellent tutorial on how to, well,

… help you add a cool effect called the “cover flow/open flow” effect to any of your iphone apps. This is cool in two ways actually. One it adds animation kind of effect to your app and the other, its very easy to build too…

It’s based on the OpenFlow project that we actually mentioned in passing before, but if you haven’t checked that out yet this is a great place to start!

Continue Reading →

Tip: TCP and SSL

You may have noted in QA1652 that is now possible to use NSStreams for your TCP communication needs even though the iPhone has no NSHost class, by leveraging the NSStream <-> CFStream toll-free bridge; but we’ll bet you didn’t know that you can encrypt them with SSL easily:

… The way that we enable SSL encryption is to simply use setProperty:forKey: on both streams, setting the key NSStreamSocketSecurityLevelKey to a value that specifies the version of SSL to use. If you want to tell NSStream to use the highest version supported in common with the remote connection, specify NSStreamSocketSecurityLevelKey. That’s what you’ll usually want…

However, that’s for a somewhat optimistic value of “easily”:

… This code will work if everything is perfect. However, by default, SSL support in NSStream is a little paranoid. It won’t, for example, use a self-signed certificate or an expired certificate to establish a secure connection. NSStream does a number of validity checks when establishing the secure connection, and if they don’t all pass, the streams appear to be valid, but no data gets sent or received. This is somewhat frustrating…

Read the whole article for further advice and sample code!

Continue Reading →
Page 60 of 90 «...3040505859606162...»