Archive for 'Programming'

OpenGL roundup

Here’s a blog chock full of meaty programming goodness we hadn’t stumbled over before: iPhone Development. The particular post we found a reference to was a collection of OpenGL articles from December,

These past three days have seen a flurry of postings. I thought I’d just do a quick table of contents to the various tutorials and postings I’ve done recently, in the order they should be read:

but there’s been a good bit of updates since then. Catch them all by looking for the OpenGL ES tag, or if you’d like a bit of a refresher the OpenGL From the Ground Up series, but we’ll draw your attention particularly to this post providing an updated version of the Xcode template post above:

Here is a new version of my OpenGL ES project template for Xcode. This version adds a class called “OpenGLCommon.h”, which contains data structures and inline functions for vertices, vectors, triangles, etc. – mostly stuff from the Wavefront OBJ class that has generic applicability, backported into the template.

h/t: iPhoneKicks!

[UPDATES]

And here’s another good OpenGL ES article at Dr. Dobbs written by the author of The OpenGL SuperBible, which if you don’t have we recommend you buy immediately.

Another roundup post with some new links — and the blog it’s from has lots more OpenGL stuff!

And here’s a very good iPhone focused series of OpenGL tutorials — up to #4 on 09.05.15!

That no glBegin()/glEnd() bit got you stumped? Read OpenGL Vertex Buffer Objects (VBOs): A Simple Tutorial!

Continue Reading →
1

AppKido

Just in case you didn’t know, that handy-dandy Cocoa documentation browser AppKido comes in an iPhone-specific version these days.

AppKiDo is an API documentation browser for Cocoa and iPhone programmers. It helps you quickly find the doc you want, whether it’s for a class, protocol, function, type, or constant. AppKiDo parses the headers and HTML doc files that were installed with your Developer Tools. It presents the results in a form that is easy to navigate.

AppKiDo-for-iPhone is just like AppKiDo (and is built from the same code base), but for iPhone developers.

Mostly we find the Xcode organization good enough for what we’re looking up, but hey, more options are always better! 

h/t: iPhoneSDK!

Continue Reading →
1

Library: JSON Framework

Here’s a handy library for you if you’re interested in getting into this JSON thing that all the cool kids seem to be excited about these days; the iPhone-friendly JSON Framework, “A strict JSON parser/generator for Objective-C“.

This framework implements a strict JSON parser and generator in Objective-C.

Download the framework, embed it in your application, and import the JSON/JSON.h header. You’re now ready to make your application speak JSON. The framework adds categories to existing Objective-C objects for a super-simple interface, and provides a JSON class for added control.

The author’s blog with release notes is here, and don’t miss the most excellent tutorial at iPhone Developer Tips!

UPDATE 10.07.30:

New JSON library announced today: JSONKit – Yet another JSON library

Not, of course, to be confused with YAJL (Yet Another JSON Library), as found in CocoaREST that we’ve been using for Twitter support.

Mind you, for other JSON needs we’ve been using TouchCode’s TouchJSON, forget why exactly now but probably it was the most developed the first time we had to do iPhone JSON stuff and inertia of library choice tends to continue around here until a compelling reason is found to invest time in deciding whether to fix or switch some problem that shows up.

Also note this post about the benchmarks here, comparing the above mentioned frameworks with Apple’s private JSON library.

And it seems that the commonly known as “SBJSON” project that this was originally about has moved to github, and reportedly will be updated soon.

Continue Reading →
1

UITableView dispatching

And today, we draw your attention to an interesting exploration of how to make your sectionized UITableView handling code less fragile by creating subclasses for each section handling.

I’ve developed a technique … allowing you to delegate the handling of each section in a table view to its own class. It is also easily configurable if you need to add or remove a section type from your controller later, and allows you to localize your changes so that you don’t have to remember to modify code in several places.

The basis of my technique is to create a main view controller for the table view, in this case calledNoteViewController, and separate section controllers for each section that inherit from anAbstractNoteSectionController class that I created. This class defines the interface for the section controllers and provides reasonable default behavior in case I don’t need specific behavior in my subclasses…

Using this technique, I was able to split up a hard to read and manage 700 line behemoth class into much more managable 80-200 line pieces and improve the readability and flexibilty of my code immensely. Hope you find this useful in your iPhone development.

Indeed. Give it a read the next time you start to find yourself buried under switch statements!

Continue Reading →
0

Flurry Analytics

So if you’re looking for some commercial solution to stick some analytics in your app, you’ve probably heard of PinchMedia, Medialets, and AdMob, which all make money via ad insertion; and far as we can tell, nobody’s making huge sums of money off those, so we haven’t looked into those further. But here’s one you might not have heard of: Flurry, which provides nice-looking analytics for FREE! — always a good price — and does it over all major mobile platforms, no less.

The problem facing many mobile application developers is that they don’t get the best analytics information on the cross-platform software they create.

That’s why San Francisco-based Flurry has launched a new mobile application analytics tool that works across a variety of mobile platforms, including the iPhone and Google’s Android. Today, the company is announcing that more than 300 developers have used its free service since the beta launched in October.

The program also works with BlackBerry and Java ME platforms (though not Palm). Flurry lets developers see exactly how consumers use their applications, and provides information on which features of the application are used and for how long.

The software is meant to give developers a tool for monitoring application usage in real time. That way, they can fine-tune the application on the fly, said Peter Farago, vice president of marketing at Flurry…

Well, that all sounds quite interesting, so we signed up for a free account. The website appears nicely laid out, and since we didn’t notice any NDA, we’ll share the API with you here:

@interface FlurryAPI : NSObject
{
}

// Call startSession with your project apiKey in applicationDidFinishLaunching
// + This call will initiate tracking of the current user session and send any previously saved
// sessions to the Flurry analytics servers.
+ (void)startSession:(NSString *)apiKey;

// Use this instead of startSession if you want detailed location information in your analytics.
+ (void)startSessionWithLocationServices:(NSString *)apiKey;

// Call logError to track any errors in your application that you would like to view in your analytics.
// + Errors are uniquely identified and correlated by errorID so two different calls using the same
// errorID will be considered the same error type.
+ (void)logError:(NSString *)errorID message:(NSString *)message exception:(NSException *)exception;

// Call logEvent to track any custom events in your application, such as user behaviors or application
// execution points. The eventName is considered unique so two different calls using the same
// eventName will be considered the same event type.
+ (void)logEvent:(NSString *)eventName;

// You should not need this function.
+ (void)setServerURL:(NSString *)url;

@end

Well, that’s short and sweet; and they provide instructions for putting logError in your uncaught exception handler for a simple crash reporter, although we still really like the looks of the previously mentioned PLCrashReporter for that. But maybe they can coexist nicely. In any case, if you are interested mainly in usage data, we don’t see any downside to jumping on board with Flurry!

h/t: VentureBeat!

Continue Reading →
3

AspenExtractor

Isn’t it just annoying as all get out the way the simulator keeps renaming where it puts your app when you’re trying to sort out how things are working? Well, for all of us that have ever resorted to putting in a log statement at startup to track the current install path, help is now at hand!

aspenextractor

I was having one of those days where dealing with the iPhone’s   
eccentricities just made me want to let loose and build a quick Mac   
app. This is the result. 

AspenExtractor is a really small utility to make peeking at the apps   
stored in the simulator easier. Instead of a folder listing of all   
those magic keys, it presents the apps as a searchable table of app   
name, bundle ID, and the file space of the documents and library   
folders. 

It’s version 0.1, just because I threw it together in a few hours, and   
it doesn’t even have an icon yet. But it does have a ‘Reveal in   
Finder’ button, which opens the folders of the selected apps, for your   
meddling about and forensics. But I figured it’d be useful, and to see   
if I should develop it into a more complete app. 

http://unlogica.com/bhamon/AspenExtractor.app.zip 

Enjoy. 

Handy little sucker to have around. Grab it now! 

h/t: iPhoneSDK!

Continue Reading →
0

View Controller memory

Here’s a tip to take to heart for your didReceiveMemoryWarning implementations in your view controllers: stash the superview before calling [super didReceiveMemoryWarning] so you don’t immediately recreate it.

[EDIT: Apparently our commenters are more clued in than both us and the original tipster. Your view controllers will get didReceiveMemoryWarning even if their view hasn't been loaded yet ... which means that if you follow this tip, the first thing you'll do is load the view. That is not a sensible response to low memory conditions. Therefore, you should check that your views have indeed been loaded!]

So, a really defensive implementation would look like this:

 

- (BOOL)viewIsLoaded
{
   return nil != _sharedPlayer; // or whatever viewDidLoad setup you can test
}

- (void)didReceiveMemoryWarning
{
   if (![self viewIsLoaded])
      return;

    UIView* superview = self.view.superview;

    // Releases the view if it doesn't have a superview
    [super didReceiveMemoryWarning];

    if ( superview == nil )
    {
        // OK. NOW we can assume view is gone.
    }

     // Destroy any caches regardless here
}

This is for the good of people who have their own memory issues, of course, not people who have imageNamed kill the system behind their back. Which isn’t us, yet. But some day it might be!

h/t: iPhoneKicks!

Continue Reading →
2

Multiple OpenGL UIViews

Here’s a tip you definitely need to give a read if you’re of the common opinion that OpenGL is only appropriate for fullscreen applications like games: how to not only integrate OpenGL views with UIKit nicely, but use multiple OpenGL views!

Things get more complicated when you want to have multiple views with OpenGL rendering. I don’t mean multiple viewports in the same screen, but multiple views in the sense of multiple UIViews. My current project, for example, has different views connected with a UITabBarController. Some of the are custom UIViews and some of them are OpenGL views.

My first thought was to try to have different OpenGL contexts for each view, but that would complicate things because I wanted to share the same textures and other resources. I know there’s a shared groups option, but that was definitely not the way to go.

The best solution I found was to use multiple frame buffers, binding each of them to the correct OpenGL view. That way, when I switch views, I switch frame buffers and everything works correctly.

Simple once you know how, isn’t it?

h/t: iPhoneKicks!

Continue Reading →
0

SQLite Resources

So maybe you’ve been thinking it’d be a good idea to get a leg up on SQLite, since it’s the data management technology of choice on the iPhone and all. Here’s a roundup of resources for you!

For starters, here is an excellent introductory tutorial to SQLite in general:

This article explores the power and simplicity of sqlite3, starting with common commands and triggers. It then covers the attach statement with the union operation, introduced in a way that allows multiple tables, in separate databases, to be combined as one virtual table, without the overhead of copying or moving data. Next, I demonstrate the simple sign function and the amazingly powerful trick of using this function in SQL select statements to solve complex queries with a single pass through the data…

Then, we have a walkthrough tutorial demonstrtating its use with the iPhone SDK:

I see many people asking for SQLite tutorials around, and since I am using SQLite for the next part in the Advanced RSS Reader Tutorial, I thought I would write up a quick tutorial on using SQLite with the iPhone SDK…

And when you want an embeddable library for your desktop and iPhone work, from those Plausible guys we keep mentioning, here’s pldatabase at Google Code:

A SQL database access library for Objective-C, initially focused on SQLite as an application database. The library supports both Mac OS X and iPhone development.

Plausible Database is provided free of charge under the BSD license, and may be freely integrated with any application.

… and if you’re looking for more, more, MORE, here’s a list put together by the guys over at MobileOrchard!

12 SQLite Resources for iPhone Developers

Continue Reading →
2

Library: PLCrashReporter

Here’s another even more useful open source library from those great guys at PlausibleLabs who did the ActorKit project we mentioned before; PLCrashReporter, a crash reporting framework you can use on the desktop, in the simulator, and on the device:

Plausible CrashReporter provides an in-process crash reporting framework for use on both the iPhone and Mac OS X.

Crash reports are output as protobuf-encoded messages, and may be decoded using the CrashReporter library or any Google Protobuf decoder.

The CrashReporter library handles both uncaught exceptions and fatal signals.

Features:

  • Implemented as a in-process fully async-safe signal handler.
  • Does not interfere with debugging in gdb
  • Handles both uncaught Objective-C exceptions and fatal signals (SIGSEGV, SIGBUS, etc)
  • Backtraces for all active threads are provided.
  • Provides full register state for the crashed thread.

Is that awesome, or what? We’ve worked with a few of these kinds of frameworks before, but this looks rather better than any of them, even leaving aside the whole works on the phone thing. Definitely going to stick this into all our projects just as soon as we have a minute. Read about it here, download the code here!

h/t: iphonesdk!

Continue Reading →
3
Page 78 of 88 «...5060707677787980...»