Posts Tagged 'Programming'


This is kinda nifty: Feel like using the status bar for … well … status, like this,

Screen shot 2011-02-22 at 10.32.44 PM.png

or to bring down a detail view?

Screen shot 2011-02-22 at 10.33.32 PM.png

What you need then is MTStatusBarOverlay on github!

This class provides a custom iOS (iPhone + iPad) status bar overlay window known from Apps like Reeder, Google Mobile App or Evernote. It currently supports touch-handling, queuing of messages, delegation as well as three different animation modes:

  • MTStatusBarOverlayAnimationShrink: When the user touches the overlay the overlay shrinks and only covers the battery-icon on the right side
  • MTStatusBarOverlayAnimationFallDown: When the user touches the overlay a detail view falls down where additional information can be displayed. You can get a history of all your displayed messages for free by enabling historyTracking!
  • MTStatusBarOverlayAnimationNone: Nothing happens, when the user touches the overlay

Check out the rest of myell0w’s projects while you’re there for some more goodies!

h/t: ManiacDev!

Continue Reading →

UITableView Revisited

We’ve mentioned before various UITableView tips from Matt Gallagher, but here’s a collection of his current practices worth checking out:

UITableView construction, drawing and management (revisited)

In this post, I’ll show you the current classes I use to construct and manage UITableViews in a number of different projects. This code is an amalgamation and evolution of some ideas that I’ve presented in a few earlier posts including my posts on heterogenous cells in a table view and easy custom table view drawing. But this implementation also chooses to do some things differently in an effort to continuously simplify the task of creating customized tables and views in iOS…

Good tips on structure, creation, etc. you may find worth adopting; we particularly enjoy the pretty, pretty cell animations in place of calling -reloadData. It’s all about the pretty. Almost as much as the shiny!

Continue Reading →

Compound Literals

Never ceases to amaze how that Mike Ash fellow keeps teaching us new stuff about the basic C language. The latest is

Friday Q&A 2011-02-18: Compound Literals

This time we were sure there wouldn’t be anything new to us, we use compound literals for field initialization every time we create a struct pretty much … and wrong again!

Specifically, did you know that compound literals are mutable?? We did not know that compound literals are mutable

One really unintuitive thing about compound literals is that, unless you declare their type as const, they produce mutable values. The following is perfectly legal, albeit completely pointless, code:

   (int){ 0 } = 42;

Less uselessly, this fact means that you can take the address of compound literals, and it’s safe to pass them to code which will modify the pointed-to value…

A fairly trivial syntactic convenience in most cases, but there is one instance where it can make your code significantly more clear and robust, and that’s when writing functions with optional parameters; things taking NSError ** for example. Which you typically write with if (*error) every few lines … unless you forget to do so until it crashes … or you keep auxiliary errors, or something tedious, anyways. Taking this mutability into account, you’d write something like

    - (BOOL)doWithError: (NSError **)error
            error = &(NSError *){ nil };

            *error = [NSError ...];
            return NO;
            *error = [NSError ...];
            return NO;

        return YES;

Well, that’s rather more straightforward and robust, isn’t it? Yes, we will definitely adopt that style from now on.

Lots of other good tips and discussion in the article and comments, so read all the way to the end!

Continue Reading →

XML Interchange: Fremont

So let’s say you’ve got XML parsing needs more complex than RSS reading, or even worse, you actually have to exchange data with some back end service in XML format. Lot of work ahead? Well, maybe not, check this out:

Fremont XML Library – “The best XML code is code that you don’t have to write.”

If you are developing software programs that integrate with external systems, be they client/server or web-service based applications, it is highly likely you’ll cross paths with XML as a data interchange format. As the number of XML messages that must be exchanged grows, the need to write XML parsing and generating code becomes very redundant. After encountering this XML coding requirement in app after app, we decided to eliminate this repetitive coding task. The result: Fremont XML Library.

Built for iOS, Fremont is an Objective C static library which provides serialization and deserialization capability between XML documents and Objective C object hierarchies. Development requires declarative definition of the mapping between XML document structure and Objective C class structure in XML format. Fremont uses this mapping, or model definition to do all of the work in translating between structures.

Eliminate the need to do XML coding, and save countless hours of development time!

Well, that sure sounds appealing, doesn’t it now? Source is on github, go wild!

h/t: @osxdevel!

Continue Reading →


Here’s a nice collection of UI classes and category additions for all kinds of little conveniences: SSToolkit. Fairly straightforward most of them, some particularly interesting ones like SSCollectionView for a selectable grid,

Screen shot 2011-02-18 at 10.40.48 PM.png

and SSPieProgressView for cute little round progress indicators,

Screen shot 2011-02-18 at 10.40.58 PM.png

so grab the code off github and check out the goodies!

h/t: @dylan_beadle, @ray_wenderlich, ManiacDev!

Continue Reading →


This is kinda interesting: Ever heard of the Xtext language development framework?

With Xtext you can easily create your own programming languages and domain-specific languages (DSLs). The framework supports the development of language infrastructures including compilers and interpreters as well as full blown Eclipse-based IDE integration…

Well, there’s a project called Applause to apply it to creating mobile apps, and applitude is its iPhone-only version:

applitude comes with a domain specific language (DSL) to express commonly used elements of iPhone applications in a very dense format. This language is made-to-measure to express iPhone apps, so instead of keywords like if, then, while it has keywords like contentprovider, tableview or cell…

The upshot is that you can write out a high-level description of your program components and get a functional Objective-C project spit out, like the example of 59 lines flat to produce this JSON data loading example:


So if you really wish you could write iPhone programs in Eclipse, and have a good bit of free time on your hands,

… applitude is intended as a tool for developers who like tinkering with own tools and languages. Please don’t use applitude if you don’t feel comfortable with solving issues around such a tool yourself …

– hey, looks like fun!

h/t: @iPhoneDevGuy, ManiacDev!

Continue Reading →

Tip: NSDateFormatter Localization

So you’re checking out the Japanese localization on your latest project, and hey that’s odd — your NSDateFormatter that you set to [NSLocale currentLocale] is producing output rather unJapaneseish:


Turns out, as described here on Stack Overflow, [NSLocale currentLocale] on a system with a Japanese calendar returns en_US@calendar=japanese even if the user language is set to Japanese. That seems like a rather strange and probably incorrect default behaviour, does it not?

The solution is to set it to the locale of the user’s preferred language,

[dateFormat setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:[[NSLocale preferredLanguages] objectAtIndex:0]] autorelease]];

which produces the rather more Japanese appearing


So … apparently if you want your localizations to actually work as a local user is likely to expect, you should adopt that language-based locale creation scheme. Anybody have any clue why the default works that way and if this scheme actually is the best practice?


And if you’re wondering why your NSDateFormatter date code breaks in iOS 5, why yes your NSLocale may be at fault there too:

… This is an intentional change in iOS 5. The issue is this: With the short formats as specified by z (=zzz) or v (=vvv), there can be a lot of ambiguity. For example, “ET” for Eastern Time” could apply to different time zones in many different regions. To improve formatting and parsing reliability, the short forms are only used in a locale if the “cu” (commonly used) flag is set for the locale. Otherwise, only the long forms are used (for both formatting and parsing). This is a change in open-source CLDR 2.0 / ICU 4.8, which is the basis for the ICU in iOS 5, which in turn is the basis of NSDateFormatter behavior…

Now you know!

Continue Reading →

AppKit Drawing

Good post over at Cocoa with Love on doing pretty drawing using AppKit:


In this post, I’ll look at drawing a detailed image in code by combining multiple visual elements. Unlike previous posts I’ve done on drawing in Cocoa, this will focus on the AppKit classes. The code will use NSGraphicsContext, NSBezierPath, NSAffineTransform, NSGradient, NSGlyph and show you some simple ways to export the contents of an NSView to a file…

Most of it ought to be somewhat straightforward to adapt to Core Graphics on iOS as well, for when you want your interface to look just that shiny. Oooh, shiny!

Continue Reading →

cocos2d AI: Troll Boss

So you may recall that we’ve been reasonably impressed with The iPhone Game Kit as an introduction to game programming in general and the iPhone with cocos2d in particular, especially the community development project they started with their customers; seems that’s coming along nicely, and they wrote recently to give us a heads up on a piece they’re putting out there for everyone:

AI: What cocos2d Cannot Do

The iPhone Game Kit has always provided the basic framework for creating artificial intelligence. Since day one, we’ve been showing you how to make skeletons seek, attack, and even dance. Now we will show you a few more advanced tricks, like how an enemy can perform ranged attacks, special attacks, flee, teleport, and yes, burp out crazy windstorms which send the player spinning…

And of course they pretty much guaranteed a mention here by making the example a Big Troll.

Screen shot 2011-02-14 at 11.37.31 PM.png

Fear the mighty TROLL! ARRRR!

Any-ways, it’s a nice walkthrough of adding moods, special attacks, and so forth to your cocos2d actor objects, definitely worth a read through and considering more seriously picking up that iPhone Game Kit thing if you haven’t already!

Continue Reading →

Resource Checking: Cong

Here’s a handy tool for running over your OS X apps to look for resource issues — Cong:

What is Cong?

To check for leaks, you use leaks or Instruments. To check for obvious (or less obvious) bugs, you use gcc and LLVM options, or you use the Build and Analyze feature of Xcode. To check that your code works, you test it. But what do you use to check the resources of the bundle of your application? Say hello to Cong.

Checking what is obvious to stop being oblivious

Cong checks multiple points and details that can seem obvious but which are not always known by everyone. Your application may be running fine, may have won Awards and still be not perfect. For instance, did you know that there is a limited set of characters allowed for a bundle identifier and that ‘_’ (underscore) is not one of them? Did you know that the recommended encoding for .strings files is UTF-16? Did you know that the CFBundleGetInfoString key is deprecated for Info.plist files?

Looks handy, yep. So we ran it over our last OS X release, and …

Screen shot 2011-02-13 at 11.57.22 PM.png

… and so it actually is handy. Fancy that. OK, straight into our regular toolchest that one goes!

h/t: xcode-users!

Continue Reading →
Page 40 of 90 «...1020303839404142...»