« March 2009 | Main | May 2009 »
Posted at 10:05 AM in News | Permalink | Comments (0) | TrackBack (0)
You can easily use the JSON (JavaScript Object Notation) data format in client-server communications when writing an iPhone app. This blog is not suggesting that JSON is a more superior format for data exchange than its counterparts such as XML. In fact, we have many projects that don't use JSON. However, handling JSON is relatively straight forward in ObjectiveC.
Unfortunately, Apple iPhone SDK (as of this writing, the latest is iPhone 2.2.1) doesn't come with a built-in JSON parser. But I found out a good one called json-framework. It is both a generator and a parser. As a generator, json-framework can create JSON data from an NSDictionary. As a parser, you can pass to json-framework an NSString that consists of JSON data and it will return a NSDictionary that encapsulates the parsed data.
#import "JSON/JSON.h"
NSDictionary *requestData = [NSDictionary dictionaryWithObjectsAndKeys:
@"grio", @"username",
@"hellogrio", @"password",
nil];
NSString* jsonString = [requestData JSONRepresentation];
{"username":"grio","password":"hellogrio"}
SBJSON *json = [[SBJSON new] autorelease];
NSError *jsonError;
NSDictionary *parsedJSON = [json objectWithString:jsonResult error:&jsonError];
NSDictionary* menu = [parsedJSON objectForKey:@"menu"];
NSLog(@"Menu id: %@", [menu objectForKey:@"id"]);
NSLog(@"Menu value: %@", [menu objectForKey:@"value"]);
Menu id: file
Menu value: File
NSDictionary* popup = [menu objectForKey:@"popup"];
NSArray* menuItems = [popup objectForKey:@"menuitem"];
NSEnumerator *enumerator = [menuItems objectEnumerator];
NSDictionary* item;
while (item = (NSDictionary*)[enumerator nextObject]) {
NSLog(@"menuitem:value = %@", [item objectForKey:@"value"]);
}
menuitem:value = New
menuitem:value = Open
menuitem:value = Close
Posted at 10:10 PM in iPhone | Permalink | Comments (4) | TrackBack (0)
A notification center object provides a mechanism for broadcasting information (“notifications”) within a task. An NSNotificationCenter object is basically a notification dispatch table. For those familiar with Windows programming, this pattern is similar to the Windows Message Loop architecture.
For example, one object may be performing a long-running operation (such as downloading a file) and needs to inform view controllers to change the view to indicate this busy state. While we could pass around a bunch of object references, it is much easier to post a notification and let the listening objects decide what to do.
First, we’ll register with a notification center to receive notifications. Here’s the call:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMethod) name:@"DoSomething" object:senderICareAbout];
So what’s going on here? First, we get a reference to the default notification center for the current task (application). Then we add ourselves (the calling object) as an observer of the notification.
The selector specifies the method we want to call when this notification arrives. The selector method takes one argument, which is an NSNotification object. It contains information about the notification, such as the name and sender object.
The notification name is the ‘message’ we are listening for. This parameter can be nil if we want to receive all notifications.
Finally, the object parameter is used to limit incoming notifications to those from a particular object. This can also be nil if you don’t care where the notification came from.
Now that we have an object listening, we can send (“post”) a notification. Here’s the code to do that:
[[NSNotificationCenter defaultCenter] postNotificationName:@"DoSomething" object:self];
The parameters here are pretty straightforward. We post the name of the notification, and the sender object (self in this case). If we don’t care about the sender object, we can use:
[[NSNotificationCenter defaultCenter] postNotificationName:@"DoSomething"]
which will set the sender object to nil in the received NSNotification.
A notification center delivers notifications to observers synchronously. In other words, the postNotification: method does not return until all observers have received and processed the notification. If you want to send notifications asynchronously, you should use a notification queue (NSNotificationQueue). We’ll save that discussion for another day.
A note of caution: in multithreaded applications, notifications are delivered in the same thread that the notification was posted, which may not be the same thread in which an observer registered, so be careful. If you are threading a long process, you should send the notification in the main thread, not the thread created for the process.
Now you have the information you need to start broadcasting notifications to your hearts content. This will help keep your application code mean and clean.
Posted at 08:52 PM in iPhone | Permalink | Comments (0) | TrackBack (0)
Scrum is a bit like 20th century politics. You have your burn-down crazed fascists, your ground-up "power to the coding plebe" reds, greedy ladder climbers hiding under the guise of scrumocracy, and on very rare occasions... responsible elected representation.
Fascism
Let's deal with the fascists first. Your average scrum doctrinaire falls back on phrases like "command and control" to describe the tired, archaic waterfallists. They should poke their own chests with that finger. I'm going to stick my neck out here and suggest that a large percentage of businesses practicing scrum err on the side of a Gestapo-like control. Why? Well let me answer you with a question: What do you think got your Product Owner or Director of Engineering their job in the first place?
Answer: great references, perfect school grades since the age of two and never, ever screwing up. These guys are simply NOT going to let the project fail. They are a proud and elite race of corporate warriors dreaming of business Valhalla (a promotion, crown, or scepter) and the scrum team had better get behind that.
Now occassionally even a proud fascist has to hide their true nature. So while the business proponents listen gently to your Fibonacci estimates during planning poker, you can be sure that behind those polite smiles lies a calculator...translating to hours and days...translating to reich marks. "Are you SURE that's a 13, Bob?" - strained silence.
"Individuals and interactions over processes and tools"
You got it, that's from the scrum manifesto. So why the Mingles, the Jira GreenHoppers, the ScrumDesks and the plethora of other surveillance tools on the market? Whatever happened to good 'ol 3M sticky notes and a whiteboard? Rightwing scrumists are staunch apologists for complex tools and doohickies and demand that their troops log a good 10-15 minutes per day up and down and up and down the square.
Not only does this daily logging crush the team's will, impede creativity and keep them in lockstep, it also allows the scrum dictator to assess performance from the comfort of their bunker (cube) without the burden of attending standups. Who wants to suffer the humiliation of being called a "chicken" in public? While I can't exactly answer that, I can claim with confidence that a self-respecting despot will not.
A strong ruler does not tolerate insubordination, and this makes the proponents of the communist school of scrum (described later) intractable enemies that need to be rooted out and destroyed. The reds want to empower the team itself to make decisions and write the schedule, and this flies in the face of middle management's divine right to rule.
A dictatorial stakeholder will often recruit allies and moles from among the scrum teams in order to attempt to dismantle the scrum process and consolidate power (military coup towards a waterfallist dictatorship) or to bend the scrum process to their will and claim credit (imperialist scrum by mass popularity). It is these two scenarios which scrum-members of communist ideals most fear and have vowed to fight.
Coming soon in Part 2: Communism
Posted at 08:46 PM | Permalink | Comments (0) | TrackBack (0)
Last Thursday KillerDeals v1.0.1 hit the shelves in the iPhone AppStore. It was only a minor update to fix a few bugs that appeared post release. So we got right to work hammering out a quick fix and Apple approved the update in no time flat. This was good news.
The necessity for the "emergency" update got us all really talking about the future of this application and where we want to head in the future. Here's a short list of the plans that will be rolling out over the next few releases:
In summary, I guess you can expect KillerDeals just to get better with every release. Remember we are exicted to here from our users so drop us a note or leave us a blog comment. We'll be waiting.
Posted at 08:19 PM in iPhone, News | Permalink | Comments (0) | TrackBack (0)