Posts Tagged ‘iPhone’

FTUtils Fork

Friday, April 9th, 2010

I recently forked FTUtils to provide some functionality I needed for FJSTransitionController.

These changes may be of use to others as well.

1. Diagonal direction control.
For when you want to slide a view in from the corner of the screen.

2. Enclosing View support.
This is a bit convoluted, but: All animations in FTUtils are assumed to move in and out of the full screen.
When would this be an issue?
If you perform 2 animations at the same time that are enclosed in a view that is less than full screen. Basically, this boils down to the animation curves will be “out of sync”.

iPhone OS 4 and Backgound Tasks or “Why We Don’t Have a Calendar API”

Wednesday, January 20th, 2010

This has been on the burner for a while. With all of the iPhone OS 4 / iPad / iSlate hoopla, I figured I better get it out the door before it all becomes a moot point.

One of the most perplexing omissions in the current SDK has been the CalendarStore API. It seemingly goes hand-in-hand with the AddressBook APIs and is every bit as important for contact management on a mobile device.

But alas, here we are on OS 3.1.X without any support for accessing a user’s calendar. Not even the “second-class citizen” readonly kind.

Although I’m sure the iPhone team at Apple has a pretty big todo list, I can’t help but think there is something more to this mystery…

I submit to you, the reader, that the forthcoming Calendar API is intimately linked to a background processes API. Huh?

I know, but let me explain.

When iPhone OS 3 appeared on the scene, Apple bestowed upon us a gift known as Push Notifications. But lets face it, they suck. For one, they only serve a few specific types of applications. And, perhaps even more detrimental, Push Notifications are hard. Hard to implement. Hard to host. Hard to scale.

Now some will disagree regarding degree of difficulty in setting up a Push Notification server, but none can argue that requiring developers to deploy a server just to fake background tasks is ludicrous.

But to my point: If only we had something like Push Notifications, but more flexible with no server requirement. Also, why not let us execute arbitrary snippets of code when our app isn’t running.

Now were getting somewhere. So, lets put it all together.

I have an app, say an alarm clock app (I know easy example). I want to schedule an alarm, so I call the calendar API and schedule an event.

CalAppEvent *newEvent = [CalAppEvent event];
[newEvent setStartDate:someDate];
[newEvent setRecurranceRule:hourly];
CalCalendar* appCalendar = [[CalCalendarStore defaultCalendarStore] sharedAppCalendar];
[newEvent setCalendar:appCalendar];
[[CalCalendarStore defaultCalendarStore] saveEvent:newEvent span:CalSpanFuture error:nil];

But wait, instead of a simple alarm, maybe I want to play a sound file from my app bundle and deliver a context specific message to the user. Maybe I even want to open a network connection.

If only we had an easy way to capture lexical scope and pass off some code to be executed by another process. How about:

[newEvent setAlarmBlock:myBlock];

Now when my event fires, I can run any arbitrary piece of code!

Now you see the possibilities. Is this true background process support? Not quite. But it is close, very close.

It provides nearly all the flexibility we need, while preserving battery life. Not to mention it avoids deploying and maintaining a server. We’ve effectively leveraged existing technologies (albeit 10.6) and since the calendar process is always running, why not exploit it for all of our multitasking needs?

Additionally, this implementation provides users with a familiar, easy to understand UI for managing background apps: the Calendar app. Simply open the special “Background Tasks” calendar to view all upcoming events scheduled tasks all of your apps.

Of course this is all speculation as I can assure you I have no inside information. I am sure that Apple has a much more elegant solution, but I can’t help but think I am on to something…

Thank you for indulging me in my little though experiment.

Development Links: Redux

Monday, December 28th, 2009

This is an update to my previous post

Below is a list of my subscribed developer feeds along with a link to each home page.

At the end of the post you will also find an OPML file if you are so inclined

Enjoy!

First are the Aggregators:

All development feeds:

And if you would like to add these straight to your favorite feed reader, here is the OPML file:

google-reader-subscriptions.xml.zip

Lastly, I used this little web app to parse my opml file.

Open Source iPhone: FTUtils or “Super Awesome Canned Animations for the iPhone”

Thursday, December 17th, 2009

Are you using this?

You should be.

FTUtils contains several classes that allow you to easily add semi-complex animations to your app, for “free”.

It’s a nice abstraction of Core Animation (which is a great abstraction of OpenGL + Quartz in it’s own right)

Check out the demo app to see what you can do.

Open Source iPhone: Resources

Wednesday, November 18th, 2009

Great Resource, tagged and organized:

http://cocoaheads.byu.edu/resources/open-source

Originally suggested in this Stackoverflow question.

Obscure iPhone: viewDidLoad and loadNibNamed

Tuesday, November 17th, 2009

Quick tip.

Sometimes, instead of traditional nib loading, you may want to use the following method:

[[NSBundle mainBundle] loadNibNamed:@"MyViewController" owner:self options:options];

For instance, if you want to provide a runtime replacement for proxy object in your nib (see UINibExternalObjects).

If you do this and you also need to perform setup after the nib loads, you’ll come across an unexpected behavior.

viewDidLoad will not be called (Nor does awakeFromNib).

I wouldn’t classify it as a “bug”, I can see the rationale, but it is dubious and I have (so far) been unable to find any documentation on this behavior.

So if you do need to do some setup, place it in viewWillAppear (You are using a UINavigationController or UITabBarController, aren’t you?).

We Finally Got It! (In App Purchases)

Thursday, October 15th, 2009

We now have in app purchases for free apps (read: trial ware).

It’s not quite perfect, as I am sure most developers would like to allow full functionality to users for a timed duration. (Maybe this will be allowed?)

From a consumer side, I hope this isn’t abused to much.

I have a strong feeling that we will see much more of a lash back if users of free apps are constantly bombarded to make in-app purchases.

Understanding the Objective-C Runtime

Sunday, September 13th, 2009

The runtime has been a bit of a mystery to me.

To be sure, I have yet to explore some of the more dynamic aspects of Objective-C/Cocoa in my applications.

In fact, as many know, you can move along quite happily though your Cocoa/iPhone programming without directly daling with it. Others might not realize what’s “under the hood”.

If you really want to have some fun, you will need some fundamentals.

To this end, Mobile Orchard last podcast featured Rogue Amoeba’s Mike Ash who gave an overview of the runtime.

MDN also released episode 7 of the MDN Show which goes into more depth in an interview with Jonathan Dann of Sofa.

If these podcasts wet your appetite, Mike Ash has also produced a nice series of blog posts on the subject as well.

I’m sure you will find other great resources in the community as well, but this should give you a good head start.

Open Source iPhone – Glossy Buttons

Friday, September 11th, 2009

The buttons in the iPhone SDK suck. There, I said it.

Almost everything on the iPhone round, glossy and “3Dish”.

Except the standard RoundRect buttons included in UIKit.

Of course we can go off and use one of many drawing apps to crank out some nice glossy buttons, but there a few problems with this approach.

First, you have to be at least competent in using some advanced drawing tool.

Second, any buttons you create are static and must be shipped as a resource in your app. It is acceptable to want to generate multiple colors on the fly.

To solve our dilemma, we can use the work of two other people.

Matt Gallagher posted a great article on generating gloss gradients a while back.

It’s quite informative in explaining and implementing the effect. You can run a OS X app and play around with the setting.

The code didn’t quite work on the iPhone because of the absence of NSColor.

So we have two problems. First, we need to adapt the code to the iPhone. Second, we need to add this code to UIButton as a category.

Good news everyone! It’s already been done.

More than that, you can follow a 5 step tutorial taking you through the process of building the code and some explanation behind it.

The first post of the series can be found here.

I would credit the author, but I think he (or she) has gone through great pains to omit his (or her) name from the blog. (Or maybe I’m just too dense).

Update: Michael Heyeck wrote in to claim his awesome work and updated his “About” page to be a little more forthcoming.

Anyways, try it out. It works good for making glossy buttons pretty quickly and it is tweak-able.

Open Source iPhone – JSON Data

Friday, July 24th, 2009

I’ve used/repurposed several open source projects for use in my code.

If you’re not trying to use someone else’s code as much as possible, you’re not doing OOP.

I won’t call this a series, but I would like to showcase some of the great code that is out there waiting to be used. All you have to do is drop it in your project.

This time I’ll point out a framework that I use very frequently:

json-framework (available on Google Code)

It’s drop dead simple to use. You give it data, it gives you a Cocoa Object, end of story.

Here is how I use json-framework in some of my code.

JSON.png

The SBJSON class gives you back a NSArray, NSDictionary, or an NSError (pointer reference).

If you need to parse JSON data, check it out.