Posts Tagged 'Programming'

Source: FTUtils

Oooh, here’s some cool stuff: a bunch of nifty canned CoreAnimation routines called FTUtils:

The code in FTUtils is common utility code extracted from Free Time Studios iPhone projects. Currently, there is only one primary utility (FTAnimation) and some simple preprocessor macros. Some unit tests exist for the code, but more are needed.

OK, it could be described more enthusiastically, along the lines of “DOZENS OF TEH AWESOME CORE ANIMATION FX!1!one!”

But hey, if you want that little extra bit of groovy animation polish in your app — and who, we ask rhetorically, doesn’t? — it’s definitely worth checking out: see the video at the above link or just grab the source off github and run the demo!

h/t: The Flying Jalapeño Lives via iPhoneFlow!

Continue Reading →

Cocoa Architecture

Here’s a post worth reading over at M Cubed on comparative architectural strategies in Cocoa:

A while back I wrote a post on how I was pushing towards making my apps much more manageable, by separating my once monolithic app delegates and nibs into various view and window controllers. Yesterday Justin Williams wrote a post on his blog about Getting Started with Core Data, Bindings and NSViewController

Justin’s post included a project he’d worked on, implementing core data tutorial application from CocoaDevCentral using several window and view controllers rather than one monolithic class and nib. The way he built his version was quite interesting, as it was differently to how I would have approached the task. As it was a relatively simple project, I thought it would be of benefit to some to provide an alternate way of building the same app. I don’t think there has been two Cocoa developers giving two different ways of implementing an entire app before…

No, if there has been, we’ve missed it. We’re always on the lookout for insightful articles about the use of Core Data, and this quite thoroughly qualifies on that count, but even if that’s not one of your main interests there’s still a lot of insight to be gained here!

Continue Reading →

XML Parsing

If you’ve got any XML-parsing tasks on deck, here is a most exhaustively thorough comparison of your options:

How To Chose The Best XML Parser for Your iPhone Project

We hadn’t even heard of all of these, actually. So far we’ve only needed to parse data feeds in our iPhone projects, so we’ve just used the SDK’s NSXMLParser for trivial jobs, and for heavy lifting the TBXML parser we mentioned here, which does indeed seem to come out well in this comparison too; but if we ever run into a situation where editability is required, from a quick read through here looks like GDataXML is a solid frontrunner for that. But options are always nice!


RaptureXML is a new attempt at making usage easy!

Continue Reading →

Website Snippets

Here from the awesomely-named Cats Who Code blog is an article of 10+ Useful Code Snippets To Develop IPhone Friendly Websites — some of which are interesting for use in your UIWebView-presented embedded content as well, looks like:

  • Detect iPhones and iPods using Javascript
  • Detect iPhones and iPods using PHP
  • Set iPhone width as the viewport
  • Insert an iPhone specific icon
  • Prevent Safari from adjusting text size on rotate
  • Detect iPhone orientation
  • Apply CSS styles to iPhones/iPods only
  • Automatically re-size images for iPhones
  • Hide toolbar by default
  • Make use of special links
  • Simulate :hover pseudo class

The blog looks pretty interesting in general if you’re into HTML, WordPress, etc. at all. Which, yeah, we will be one of these days, at least to find a theme that’s actually readable to save our Gracious Readers’ eyes. Just as soon as things slow down just a smidgen. 2018 is looking not bad. So far…

Continue Reading →

Tip: CodeSense FAIL

Hey, you noticed in your new Xcode projects recently that CodeSense is only working for your code, not SDK frameworks? And haven’t been able to figure out why? Yeah, us too. Turns out the problem is turning on analysis — aka “RUN_CLANG_STATIC_ANALYZER” — in your base .xcconfig, as noted here on OpenRadar:


For any project of mine in which RUN_CLANG_STATIC_ANALYZER is set to YES, CodeSense symbol lookup fails for non-explicitly-imported symbols (i.e. Foundation/UIKit classes and methods, etc.). Because the CodeSense index fails to build, code completion and option-double-click documentation searches also fail.

Ah, so that’s the trick! And why yes, commenting that line out of our base config file and clicking ‘Rebuild Code Sense’ in the project info has indeed given us our SDK class option-click back. How nice!

However, we really really don’t want to do without the analyzer, as it’s been pretty darn useful in identifying subtle oversights. And in the occasional case where it misidentifies leaks and the like, we’ve tended to adopt the attitude that “well, if the analyzer can’t figure out how this works, the chances are pretty good nobody tasked with maintaining this in future will be able to either”. And in our 20+ years at this programming thing, we have increasingly come to the conclusion that in virtually all cases the only metric worth evaluating code quality by — after “correctness of result”, of course — is not its efficiency, not its cleverness, not its elegance, but its maintainability.

So we’re now trying the workaround of enabling clang only in the debug configuration and leaving it off for the AdHoc/AppStore configurations, and so far that appears to indeed be working and providing us both CodeSense and analysis while developing. But if any of you have a better solution, please share!

Continue Reading →

Framework: DTSpringback

So you know how you’re supposed to maintain the complete usage state of your iPhone app and restore it on startup? Yeah, we never bother with that all that much either. But should we ever have a situation that requires that kind of state maintenance enough to get us motivated to actually do something, here is Springback to help us out:

A small cocoa framework for resurrecting an object graph, specifically designed with a view controller structure on the iPhone.

Skipping through, it looks nicely thought out, apparently even handling modal dialogs. Pretty nifty stuff.

And there’s some other interesting looking stuff by the author to check out too, for instance DTMusicModel “A Core Data based framework for quickly accessing the music information in MediaPlayer.” Yes, we’ll definitely dig around here some more whenever we have a spare minute…

Continue Reading →

Switching from Core Data

Here’s a thoughtful piece on when not to use Core Data that’s worth reading:

… I optimized as much as I could, spent tons of time in Shark, went all multi-threaded with Core Data, switched away from my own queuing system to NSOperationQueue, optimized the XML parsing, etc. But performance and memory use on my first-generation iPod Touch (my development test device) was still not nearly good enough with a big unread count (of around 10,000 items).

At that point, having done everything else, the remaining issue was clearly Core Data. So I tried more things, re-read everything I could about Core Data performance (for the nth time), ran experiments, spent tons more time in Shark. Trying to get it good. No go.

Finally I realized I had to switch away from Core Data and use SQLite more directly. Not completely directly — I use FMDB, a lightweight Objective-C interface that works on Macs and iPhones. Gus wrote it. It’s good…

Definitely worth reading over before putting together anything with heavy data manipulation requirements, yep!


Check out the other reactions that MobileOrchard collected!

On Using SQLite and FMDB Instead of Core Data

marcoarment / FCModel – “An alternative to Core Data for people who like having direct SQL access.”

Realm “is a mobile database that runs directly inside phones, tablets or wearables.”

Continue Reading →

In-App Purchasing

Well, that was pretty much completely anticlimactic.

For several months now we’ve been, well, not avoiding exactly, but deprioritizing below “panic” level — which around here, means in schedule terms roughly “you’re kidding, right?” — learning all about in-app purchase for the upcoming single app revision of the Poses series, having read all over the place about how fraught with peril and puzzlement the process of implementing IAP was. But this afternoon it looked, wonder of wonders, like there weren’t any cataclysmic events on the horizon at least until Monday; so we figured that getting started on sussing out this IAP thing would be the best use of that time block…

… and it took us about four hours to implement.

So, it definitely is not necessarily as difficult as the more fevered rantings around teh intertubes would have you believe.

First off, log into the Dev Center and read thoroughly all the relevant documentation from the mothership.

Getting Started With In App Purchase

In App Purchase Programming Guide

iTunes Connect Developer Guide

Store Kit Framework Reference

Once you’ve read those: enable IAP for your app ID in the portal, create an entry for the app in iTunes Connect if it’s a new app, create some product IDs for your purchases, and create a test user. All reasonably straightforward. (If it doesn’t seem that way, hey read the following tutorials too before digging in.)

Then, take a read through this pair of tutorials from Mugunth Kumar’s blog

In-App Purchases

Enabling reviewers to use your in-App purchases for free

and grab the MKStoreKit V2.0 source provided therein. Provides a great big leg up on getting the entire payment process up and running, pretty much just substitute in your own product IDs and set a delegate to do whatever the consequences of purchasing are, if they’re more complicated than setting a user defaults flag.

And once you’ve got that basic implementation in place, read over this series from the FlowerGarden fellow on

Displaying Store Items

Selling The Goods

Anti-Piracy Measures

iTunes Connect

for a variety of useful advice.

And as a final note, StoreKit doesn’t get on that well with the simulator, so if that’s an issue for you, look into the SimStoreKit project, “a simulated version of the iPhone’s StoreKit, for testing store UIs on the iPhone Simulator, or even on device without having to set up IAP in Connect.” Didn’t need to try it ourselves, but hey it’s always nice to have options!


The above-mentioned MKStoreKit is now at version 3 with lots of new goodies!

Continue Reading →

Tip: Sanitizing RSS Feeds

So let’s say you’ve got what’s supposed to be a simple RSS feed you’re parsing with NSXMLParser — but the clowns that put it together insist on providing it with strange Windows characters embedded in the text, so the parsing consistently chokes with illegal character errors. And, of course, the suggestion of getting Windows people to display even minimal competence on their end, well that’s just crazy talk. So, what to do? What to do?

Well, here’s a quick and easy trick to sanitize the offensiveness right out:

NSString *dataString = [[[NSString alloc] initWithData:rawFeedData encoding:NSASCIIStringEncoding] autorelease];
NSData *sanitizedData = [dataString dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];

Hey, worked for us!

h/t: StackOverflow!

Continue Reading →

iPhone Facebook URLs

So seems everyone wants to integrate their iPhone apps with Facebook these days; and it may be of interest to you to know that there’s some undocumented options to the Facebook iPhone app’s custom URL scheme to control its behaviour:

  • fb://profile – Open Facebook app to the user’s profile
  • fb://friends – Open Facebook app to the friends list
  • fb://notifications – Open Facebook app to the notifications list (NOTE: there appears to be a bug with this URL. The Notifications page opens. However, it’s not possible to navigate to anywhere else in the Facebook app)
  • fb://feed – Open Facebook app to the News Feed
  • fb://events – Open Facebook app to the Events page
  • fb://requests – Open Facebook app to the Requests list
  • fb://notes- Open Facebook app to the Notes page
  • fb://albums – – Open Facebook app to Photo Albums list

Now, what you’re really looking for no doubt — at least, that’s what we were looking for today — was trying to figure out how to get the user to be able to join a particular fan page more elegantly than loading its URL in Safari, because of course your typical iPhone user probably isn’t logged into the browser, since well there’s this native app and all.

Well, this followup post to the above claims you can do that by adding the fan page’s ID to fb://profile as a path. BUT IT LIES. Maybe the procedure described worked with whatever version was current when that was written … but with 3.12 the latest as of today, nope you can only open to your own profile; trying to load someone else’s fan page we find this — or any other sensible attempt we can think of to pass a designated page ID — fails. Bah.

Anyone out there manage to get this to work with other people’s fan pages? Or come up with some better way to handle the ‘join fan page X’ design requirement than just passing its URL off to Safari? If so, please share!

Continue Reading →
Page 62 of 88 «...3040506061626364...»