Codebreaker 2bc08752a0894eb2c7afb345286e391d

15Aug/092

Apple Push Notification

Push Test

Push Test

I was able to setup my server and mobile device (iPhone and iPod touch) to make the push notification service working. I had to send a binary data packet over SSL/TSL connection and the APNs doesn't even tell me anything back, so it was very difficult to debug the system. So if you need someone to setup the push notification, you can contact me.

25May/092

A Macro for UIAlertView

Introduction

UIAlertView is a convenient method to notify users with a short message and a couple buttons. However, it could be, actually quiet commonly, a little tedious to open up one. Just like this.

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message"
        message:@"Data was received, but could not be properly interpreted"
        delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
alert.tag = AlertInvalidJSON;
[alert show];
[alert release];

So, I decided to make a very simple macro so that I don't have to type all that. (Thanks to C)

#define Alert(tag, title, msg, button, buttons...) {UIAlertView *__alert = 
[[UIAlertView alloc] initWithTitle:title message:msg delegate:self 
cancelButtonTitle:button otherButtonTitles:buttons];[__alert setTag:tag];
[__alert show];[__alert release];}

Now it takes less time to type, and is easier to read.

Alert(AlertInvalidJSON, @"Message",
    @"Data was received, but could not be properly interpreted",
    @"Dismiss", nil);

Screenshot

uialertview

References

21Apr/090

iPhone Accelerometer Example

This is what I made in today's presentation.

Just remember the following two steps:

  1. Get an instance of UIAccelerometer, using UIAccelerometer.sharedAccelerometer method, and specify the update interval and the delegate target.
  2. Implement UIAccelerometerDelegate within the delegate target; for example, a view controller.

accelerometerexample.zip