Tuesday, July 17, 2012

Features in new Mountain Lion OS


Atmosphere is again hot with the anticipation of new Mac OS. Again, millions of 20 dollars will be added to trillion dollar Apple :) 
Lets take a quick look at the  feature list.

  •  iCloud is automatic and effortless now. Just sign in once with your Apple ID and iCloud is set up in all the apps that use it.

  • Reminder:  Set due dates and you’ll get alerts as deadlines approach. Set a location from your Mac, and your iPhone or iPad will remind you when you get there.

  • Notes: Its more noteworthy with photos, images, and attachments.Pin important notes to your desktop so they’re easy to get to. 

  • iMessage: You can send messages to anyone on an iPhone, iPad, or iPod touch running iOS 5, too.Send photos, videos, documents, and contacts — even send messages to a group. 

  •  Notification Center just like iPad—for  any new email, a message, a software update or a calendar alert.

  • Power Nap is most awesome-It periodically updates Mail, Contacts, Calendar, Reminders, Notes, Photo Stream, Find My Mac, and Documents in the Cloud,downloads software updates and makes backups with Time Machine. While updating, the system sounds are silent and no lights or fans come on, so nothing disturbs you as reported on Apple's website.

  • Dictation -It converts your words into text.And it recognizes people from your contacts so it enters names accurately. Dictation supports English (U.S., UK, and Australia), French, German, and Japanese.

  • Share Button-There is Share button throughout OS X Mountain Lion.

  • Built-in Facebook support- You can share what’s up with you right from the app you’re in. Post photos or links. Add comments and locations.OS X adds your Facebook friends and their profile photos to Contacts.

  • Built-in Twitter support- OS X Mountain Lion is designed for tweeting. Sign in once and you’re all set up .You can tweet from Notification Center, too.

  • Game Center app - You can play anyone on a Mac, iPad, iPhone, and iPod touch.Just use your Game Center account from iOS or create one with your Apple ID. Then sign in and you’re in.

  • Gatekeeper -It helps protect you from downloading and installing malicious software on your Mac.

  • Safari- When you open web pages on your iPhone or iPad, iCloud Tabs makes them available on your Mac, too. So you can pick up browsing wherever you left off.  Safari saves entire web pages in your Reading List,not just the links. 

Tuesday, June 12, 2012

iOS 6: All the new Features Coming to your iOS device this Fall



Apple's new iOS 6 comes loaded with new features. From completely new Maps to a new version of the voice-activated personal assistant Siri to Facebook integration. And Passbook - Apple's new app that controls coupons, boarding passes, cards and coupons - is really neat.

This version looks quite sweet. These will be the new features of your iPhone and iPad.

1. Siri

Siri keeps being updated. The new version on iOS 6 does sports scores and stats. You ask what was the score for the Giants and she will reply that they were downed by the Rangers. It will also tell you about batting averages.

Siri is being integrated with Yelp and OpenTable. You could ask for a good italian restaurant near you and she will tell you about the best ones using Yelp information and allow you to make a reservation with your voice using OpenTable.

It's also bringing movies with IMDB for reviews and information, and Fandango for tickets. You can ask for a movie that stars your favorite star or director, and she will find them for you. The result screen is quite nice, with integrated Rotten Tomatoes ratings. I wonder how much more useful this will make Siri. Would people use it more now that it has some neat integration with these useful services? Tell us in the comments.

Siri is also being updated to other languages. They are adding Canadian French, Spanish for Spain, Mexico and the US. Also Italian in Italy and French, German and Italian dialects for Switzerland. Plus Asian languages: Korean plus Mandarin and Cantonese in China.

She will be available on the iPad. Many auto makers—including BMW, GM, Mercedes, Land Rover, Jaguar, Audi, Toyota, Chrysler and Honda—will also integrate Siri in their cars.



2. Facebook integration

Facebook is now completely integrated with the iPhone. You will be able post to Facebook from Apple's apps, just like you can do with Twitter. That includes images directly from the Photos albums. Or location from Maps. It's even integrated with Siri. And the Calendar application, so birthdays and events are automatically synchronized at all times with Facebook.

The most interesting thing is that, as I said in the rumor round up, there will be an API for it, so every developer can enjoy the same Facebook services. This means that your favorite applications would be able to easily post things in Facebook or get Facebook information easily.



3. New Phone features

This is a welcomed surprise: they are updating the Phone application, which has remained almost frozen for all this time. I like this feature, which Nokia already had some years ago: you can reply automatically with a message when someone calls you. The phone will show you a list of messages like "I'll call you later" or "I'm on my way" that you can click and automatically send while rejecting a call.

A new "Do Not Disturb" preference will turn off calls and messages at night. The neat thing is that notification will come but the phone will not sound or light up. I'm quite happy about this feature, because the lighting up can be quite annoying. Still, you can mark some phone numbers as important, which will allow them to disturb you at night.

On the other hand, if someone is calling you repeatedly and continuously, the new Phone app will push the call assuming it is an emergency. This, I'm sure, will be misused several times.



4. New Facetime
The first big news is 3G support for Facetime. You will be able to call someone using Facetime over the 3G network. The quality will not be as good as Wi-Fi, but it will be supported.
Another neat feature of the new Facetime is that the device IDs are being unified. In iOS 6, when someone calls your phone number, you will be able to answer the call from your iPad or your Mac straight away. The ID unification will be the same with iMessage, which will hopefully fix the confusion. Sometimes users get messages in one device but not the other one.
5. New Safari
Safari is getting the live synchronization of tabs with desktop Safari, so your browsing experience is unified across devices using iCloud. It also uses iCloud synchronization for an Offline Reading List, which allows you to read a story that you have marked to read later without a web connection. This is pretty neat for subway commuters and flights.
One of the best features, however, is the new support for web forms uploads. To me, it has always been so frustrating not to be able to upload a photo to a web site. Now you can click on the upload button, a Photo browser will appear, and you will be able to upload. I wonder if this service will also be available for other file types, like Pages documents.
Safari will also support full screen navigation while in landscape mode. Entering this mode will eliminate any app navigation element and just leave you with the web page content.


6. Photo streams on iCloud
In the past, iCloud allowed you to upload photos constantly to your personal stream. Now you can share your photos specific streams with selected people. You can pick friends and they will be able to see any photos you upload in a dedicated stream automatically, constantly updated. Everyone will also be able to comment on them.
It's like creating private Instagram feeds from the Photos app.


7. Mail
Mail's Mailboxes have also been revamped for a new feature: VIPs. You can mark people as VIPs, and their emails will automatically go into a special folder. This is going to be the only folder I'm going to read from now on.
Another much-needed feature is attachment of photos and videos straight from the New Message window. At last!


8. Passbook
This a new app. It will allow you to have all your tickets and coupons—airplanes, train, movies, concerts, sport events, gift cards, loyalty cards, whatever—in a single wallet. It's quite pretty and useful. If you have a gift card, for example, it will show the card balance after you use it. It will also alert you about nearby shops when you have shop's coupons or gift cards.
Another really neat feature of Passbook—perhaps the best one—is that it will update your gate number in your boarding pass in real time.


9. Guided access
The iPhone is very popular among people with disabilities of any kind. Apple is adding a new feature called Guide Access to iOS' accessibility services. Educators will be able to only activate parts of the screen, so autistic kids or people with other disabilities can stay focused on certain areas.
You can also put an iPad in single app mode now, which is also useful for schools: now teachers can send tests to students' iPads, locking them in the test so they can't go into other apps to cheat.
10. New maps
The new Maps—fully developed in house—seems pretty insane. It's a complete overhaul and it truly looks fantastic, much better than the old Google-based version. Here are all the new features.


New cartography
Apple bought a cartography company in 2009 and this the result of that. The new Maps app has new cartography, completely different from the one provided by Google. This includes new points of interests, restaurants, shops... everything is new. We will need to compare to see what's better.
Vector based vs bitmap
The new maps are not bitmap-based anymore. Say goodbye to the horrible and slow tile loading. Now they are vector based, which means faster loading—it still loads sectors, but very fast based in our hands on experience—and smoother, much better graphics.
Turn-by-turn navigation
At last, Apple's Maps will provide with turn-by-turn navigation, just like any other car GPS app. It looks quite good. We have tried and it seems quite neat, with Siri driving directions and 3D view, with clear signs.
Business information card
Now every location in Maps includes a card that gives you all you need to know about it. If it's a restaurant, it will show you reviews and ratings, along with photographs.
Siri integration
Siri is completely integrated with Maps. You can ask for directions with your voice, it will guide you while driving and, if you ask her something like "Are we there yet?", she will answer you with the estimated time of arrival. And tell you to shut up.
Traffic information
Traffic information loads constantly, even when you are not looking at it. If Maps detects a change on traffic conditions that would make your trip faster, it will ask you to reroute.
3D view
Apple bought another company last year with cool 3D maps technology. Looking at the demo of their Flyover feature, it was worth the price. This thing is impressive. It looks like a movie, but it's rendered in 3D graphics in real time.
Missing features
But for all this neat features and awesome interface, there are two important missing things in maps: public transit information and StreetView.
The first is extremely important for those in big cities like New York. The old Maps give you this information easily and completely. You could really plan your commuting at any time. This feature is a must. Apple says that developers will be able to add this in their applications, plugging into Apple's Maps, but it's clearly a big miss.
Hands-on update: We tried this on our copy of iOS 6 and, when you click on the public transit directions button, it will bring you up a list of apps you can choose from. Right now, that list is empty but we imagine that, once iOS 6 is released, there will be apps that directly integrate into Maps in this third pane.
StreetView is important too when you are going to new places. It gives you a street level visual reference that the 2D maps and the new Flyover 3D view may not be able to give you. I've used StreetView many times to locate obscure restaurants and shops, and it always saves time. Apple hasn't mentioned anything about StreetView.
11. New Find My iPhone features
Find My iPhone has been enhanced. You can lock your phone with a four-digit number remotely, no matter if your iPhone wasn't set to automatically lock. What's better: you can send a message to the phone with a contact phone number and a big "Call" button, so whoever finds it can call you back.
The iPhone will automatically record all its locations after you lock it remotely.
12. New Find My Friends features
A new feature will be great for parents trying to keep their kids under Stasi-like control: they will be able to define location based alerts so, when their children leave the house or school, they will be alerted.
13. New iTunes, App and iBooks stores
iOS 6 has new stores. Right now they are not fully operative but we have been able to test the "Featured" part of the new store and it's much cleaner and faster than the previous version, with fast side-scrolling sliding of movies, apps and books.
When is it coming?
It's arriving this fall, probably when the new iPhone debuts, like before.
Which devices are supported
It will be available for iPhone 4S, iPhone 4, iPhone 3GS, 4th generation iPod touch, the latest iPad and iPad 2. So the rumors were right: the first iPad is out of this upgrade.

Wednesday, May 30, 2012

iOS Paint tool using UIBezierPath


I was going through how to use UIBezierPath and what are its possible uses.. and I must say it is one hell of a convenient tool! Ofcourse you can draw normal drawing with it as shown below and use your app as sketching pad in addition to that it adds so much convenience with the undo and redo action that I fell in love with the use of UIBezierPath. You can have simple drawing as well as pattern based brush tip. It is so easy to use this as pencil tool that I don't even have words !

You can initialize the UIBezierPath as following
UIBezierPath *myPath = [[UIBezierPath alloc] init];
myPath.lineWidth = 10;
brushPattern = [UIColor redColor]; // This is the color of my stroke
Then you have Touch methods which handle and track the coordinates of your touch. When your touch begins on the screen, you ask UIBezierPath to move to that touch point.
UITouch *myTouch = [[touches allObject] objectAtIndex:0];
[myPath moveToPoint:[myTouch locationInView:self]; 
As you move your finger around, you keep adding those points in your BezierPath in TouchMoved method by following
UITouch * mytouch = [[touches allObjects] objectAtIndex:0];
[myPath addLineToPoint:[mytouch locationInView:self]];
As we need constant refreshing of the screen, so that as soon as we draw it appears on the screen, we refresh the UIView subclass by calling following method in TouchMethod so that as soon as there any change in the BezierPath, it is reflected on the screen.
[self setNeedsDisplay];
Talking about drawRect Method which does all the drawing for you, you need to set the color of your stroke (stroke color means the color with which painting will be done on screen) on screen and also the blend mode. You can try different blend mode and see the result.
[brushPattern setStroke];
[_path strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];




Pattern Brush.. it just changes the custom pattern color of the paint brush and allows you to use a custom image-pattern to be used instead of any specific color (which was red in our case)

myPath.lineWidth = 10; //This can help you in setting width of the stroke/brush
brushPattern = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"pattern.jpg"]]; // You can set pattern in your color of your brush so that the stroke will appear with pattern of your image


Adding Undo/Redo feature

We don't have to do much after this step for adding the undo/redo feature in the existing code.
Add following lines to header (.h) file
{
  NSMutableArray *pathArray;
  NSMutableArray *bufferArray;
}
- (void)undoButtonClicked;
- (void)redoButtonClicked;

First, we declare two NSMutable arrays, one each for 'undo' and 'redo' steps. Then we declare two methods that gets called when we want to undo/redo.

Go to implementation file (.m) and lets start be looking into touch delegate methods:
 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    myPath = [[UIBezierPath alloc] init];
    myPath.lineWidth = 10;
    UITouch *mytouch = [[touches allObjects] objectAtIndex:0];
    [myPath moveToPoint:[mytouch locationInView:self]];
    [pathArray addObject:myPath]; 
}
Here, whenever a new touch is detected, we initialize a new UIBezierPath and add it to "pathArray" (for undo steps)
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *mytouch = [[touches allObjects] objectAtIndex:0];
    [myPath addLineToPoint:[mytouch locationInView:self];
    [self setNeedsDisplay];
}
Next, each time a movement is detected, then we call 'setNeedsDisplay' and redraws the view which in turn calls 'drawRect' method
- (void)drawRect:(CGRect)rect

{
    [brushPattern setStroke];
    for (UIBezierPath *_path in pathArray)
        [_path strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];
}
Since, 'pathArray' contains all the UIBezierPaths, it loops through each of them and paints them on screen.
Below are the actions that gets called upon when we click on undo/redo buttons:
- (void)undoButtonClicked {
   if([pathArray count]>0))
   {
        UIBezierPath *_path = [pathArray lastObject];
        [bufferArray addObject:_path];
        [pathArray removeLastObject];
        [self setNeedsDisplay];
    }
}

- (void)redoButtonClicked{
    if([bufferArray count]>0)) {
        UIBezierPath *_path = [bufferArray lastObject];
        [pathArray addObject:_path];
        [bufferArray removeLastObject];
        [self setNeedsDisplay];
    }
}

When undo button is clicked, we remove the last object from pathArray and save that object to 'bufferArray' - which stores all UIBezierPath for redo.
And when redo gets clicked, we remove the last object form 'bufferArray' and adds it to the 'pathArray'.
We ask the view to redraw itself again after performing any one of the above stuff.

That's all. This short code snippet lets you perform touch sensitive paint on iOS devices with properly working undo/redo functionality.

The complete code of above tutorial can be found on github.

Thursday, May 17, 2012

101 Reasons not to buy Windows Phone 7.5

Windows Phone is a mobile operating system developed by Microsoft, and is the successor to its Windows Mobile platform, although incompatible with it. Unlike its predecessor, it is primarily aimed at the consumer market rather than the enterprise market. Although Microsoft is doing every bit to popularize its new mobile OS, including new Metro style UI, "Mango" update, upcoming update to "Apollo - WP8", partnership with Nokia, still this Windows Phone 7.5 seems not to make itself a huge hit in the market which has already been captured by Android and iOS.


WP 7.5 (Mango) is already in its second generation but it still has many restrictions, limitations and serious usability issues. This is a list of its shortcomings as compared with other smartphone OS in the market. We are not comparing special features or abilities but those which have become the norm for all smartphones and even dumb phones. An Android, Symbian or MeeGo phone would have almost none of these shortcomings. An iphone share some restrictions with WP7.5 but is still miles ahead. Even the Nokia N9 running the first generation MeeGo OS is far better with none of the disastrous issues which impact on the sheer usability of the phone.


Here are 101 REASONS NOT TO BUY A WINDOWS PHONE 7.5
OS LIMITATIONS
1. No true multitasking - apps are frozen in the background.
2. No Divx/Xvid video codec support. Zune will convert with loss of quality.
3. No mass storage mode.
4. No micro-SD card support.
5. Only support up to 16GB storage .
6. No filemanager. Directory system is totally opaque.
7. Need Zune to transfer files. Zune will only transfer photos, videos & music. All other files need to email/upload to yourself.
8. Your contact details are automatically uploaded to cloud service whether you like it or not.
9. Limited to 800x480 resolution.
10. No wi-fi hotspot.
11. Cannot use any MP3 file as ringtone except those with strict constraints.
12. Cannot set static IP address so no connection to ad-hoc networks.
13. No VPN support for this “corporate enterprise” phone.
14. Cannot sync with Outlook.
15. Totally closed OS, cannot sideload apps outside MS Marketplace.
16. System font size cannot be changed.
17. Images and photos cannot be renamed in the phone.
18. Windows Live ID account cannot change country once set.
19. No centralized notification page.
20. Alarm clock cannot work when phone is turned off. All Nokia Symbian and Meego phones can do this.
21. The idle screen is completely blank and cannot display time or notifications.
22. Only photos allowed as email attachments, documents not allowed.
23. Bluetooth cannot stream to car audio devices (no rSAP).
24. Cannot stream audio from video to Bluetooth devices (No A2DP).
25. No support for full on-device encryption required for secure applications like mobile banking and online payment.
26. Cannot use Bluetooth keyboard.
27. Cannot silence ringtone or alarm by flipping the phone.
28. Very limited customization option.
29. Ugly 2D flat interface. Oversized fonts for headings treat you like an idiot.

USABILITY ISSUES
30. No always visible status bar for battery life, signal strength, carrier, 2G/3G wi-fi, Bluetooth on.
31. Taskmanager has no option to shut down apps you don’t want running in the background.
32. Search and Back button cannot be de-activated in apps or games and easily touched by accident which interrupt your user experience.
33. Lockscreen need to be activated to show missed call/sms notification.
34. No way to close an app except pressing back button all the way to the first screen.
35. Tiny fonts in messages is very hard to read for those over 45.
36. Cannot edit playlist or create new playlists from phone.
37. Cannot delete a song from phone.
38. Cannot search your music collection on the phone.
39. Cannot close music player, can only pause. Music player on lockscreen will stay until you reboot.
40. No progress bar for current track playing and no indication which track in an album is playing
41. Cannot lock screen orientation.
42. Online and phone contacts are mixed together with no ability to filter.
43. Cumbersome dialing with no smartdial. No way to create a ‘Favourites’ list of phone contacts
44. Cannot save draft sms messages.
45. Call history only show phone number type. If a contact has multiple phone nos. for a type the number used is unknown.
46. Cannot recognize phone numbers in sms or email to save or use as calling number.
47. Text messages can only be deleted one by one.
48. Cannot select multiple pictures for deleting, sending or uploading. They must be done one at a time.
49. Notification for recurring events is only given once and none thereafter.
50. Apps are listed alphabetically with no way to group by category. Can be hard to find if you don’t remember the name.
51. Calendar scheduler has no weekly view and monthly view is non-zoomable.
52. No peak/off-peak scheduling for email downloads.
53. If both wi-fi and data connection are available which one it chooses to use is unpredictable. User experiences don’t agree with Microsoft that it “typically” choose wi-fi over 3G.

FEATURE LIMITATIONS
54. No video call.
55. No haptic feedback for keyboard.
56. No Swype.
57. No flashplayer support.
58. No support for Java apps.
59. No call recording or app to do it.
60. No call blocking or app to do it.
61. No screenshots or app to do it.
62. No auto wallpaper changer and no app to do it.
63. Totally locked down os means apps which interact directly with hardware not allowed.
64. No equalizer for Zune music player.
65. FM radio doesn’t work on speaker.
66. IE browser has no text reflow, no download capability and no offline reading.
67. No 3rd party browsers allowed except those based on IE.
68. No built-in pdf file reader, need to buy app.
69. Cannot open zip or rar files received as email attachment.
70. Cannot send or receive video by MMS.
71. Office Mobile has much less features than 3rd party Office editors like SmartOffice, QuickOffice and Polaris. Shame on you, Microsoft!
72. No native Google maps and Bing maps is useless for most countries outside U.S.
73. Email time stamp does not show the year.
74. Wide difference in apps availability in different markets and users locked to one market.
75. Not all Bing features available outside U.S.

DUMB AND DUMBER
76. One volume control for all functions including media playback, ringtones, alarms, notifications.
77. Wi-fi disconnects when screen sleeps. Too bad if you are in the middle of a download.
78. If you receive a text message when talking on the phone an audio alert will blast your ear at the full volume set. All other phones will give a soft beep.
79. Can only enter one mobile phone no. for each contact. Mobile nos. entered in other fields will not accept sms.
80. Cannot send/receive MMS without enabling 3G data connection. MMS does not use 3G data.
81. Phone cannot be charged when off.
82. Need to be plugged in to wall charger to sync wirelessly (a funny definition of wireless).
83. Volume up/down buttons cannot operate when screen is off.
84. Phone will wake up and display sms content on lockscreen when locked – a privacy violation.
85. Phone can be rebooted without unlocking to bypass security lock.

FEATURES EVEN DUMB PHONES HAVE BUT WP7.5 DOESN’T
86. No bluetooth file transfer.
87. Cannot handle USSD codes necessary for prepaid users to obtain services.
88. Cannot save new contacts from call history.
89. Cannot sms contacts from call history.
90. Cannot show call duration in call history.
91. Cannot delete individual calls in call history.
92. Call history does not group calls by contact.
93. Call history does not show the time of call for calls older than current day.
94. Cannot set custom sounds for different types of notifications.
95. No ringer profiles.
96. No silent option (no vibrate and no ring).
97. Cannot send/receive contact as a csv file.
98. Cannot backup sms to PC.
99. Cannot save contact to SIM card.
100. Cannot change alarm ring tone or use a MP3 file.
101. Cannot set alarm snooze interval.

Sunday, October 2, 2011

Local Notifications (iOS 4)

With the coming of iPhone OS 3, push notifications were introduced which enables an application to alert user while the application isn't running. Push notifications solved many of the issues associated with background processing. For example, when quitting the Facebook application, the server could keep you logged in and send you a push notification when a new message arrived. You could then tap on a View button that would launch the app.
This solution is great and all, but it still requires that you have an active internet connection. As of iOS4, Apple has introduced a new type of notification that can be scheduled to fire within the device itself. It requires no complicated server programming. These are known as Local Notifications.

Local notifications can be scheduled on the user’s device to fire at any given time; you can even set them to be recurring. Today, we will explore these notifications and go through a simple example of how to schedule, view, and handle local notifications.

The project will allow a user to schedule a location notification to fire off at a given date. Using the text field, they are also able to specify some text for the notification. The table view below displays a list of all of the currently scheduled location notifications within the application.

Step 1
Create a View Based Applicatin and name it LocalNotifier.

Step 2

Create all properties and dummy IBActions. Copy the code below in your .h file
@interface LocalNotifierViewController : UIViewController {
IBOutlet UITableView *tableview;
IBOutlet UIDatePicker *datePicker;
IBOutlet UITextField *eventText;
}

@property (nonatomic, retain) IBOutlet UITableView *tableview;
@property (nonatomic, retain) IBOutlet UIDatePicker *datePicker;
@property (nonatomic, retain) IBOutlet UITextField *eventText;

- (IBAction) scheduleAlarm:(id) sender;

@end


We have defined three fields, one is a TableView to dipslay all the scheduled notifications, another is a TextField where use enters the event description of any new notification to be scheduled and the last field is datePicker from where user picks the date when he wants to schedule the new notification or wants to see all notifications for that day.

Next, setup the .m file of your viewController.
@synthesize datePicker,tableview, eventText;

- (IBAction) scheduleAlarm:(id) sender {

}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}

- (void)viewDidUnload {
datePicker = nil;
tableview = nil;
eventText = nil;
}

- (void)dealloc {
[super dealloc];
}


Now it’s time to build our interface. Open Interface builder and construct an interface like this.



Step 3: Implement UITableViewDelegate and UITableViewDataSource Delegate methods to List Currently Scheduled Local Notifications

Add the following code in your .m file


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// We only have one section
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of notifications
return [[[UIApplication sharedApplication] scheduledLocalNotifications] count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}

// Get list of local notifications
NSArray *notificationArray = [[UIApplication sharedApplication] scheduledLocalNotifications];
UILocalNotification *notif = [notificationArray objectAtIndex:indexPath.row];

// Display notification info
[cell.textLabel setText:notif.alertBody];
[cell.detailTextLabel setText:[notif.fireDate description]];

return cell;
}


So, the new code here is dealing with retrieving a list of scheduled notifications. Calling the scheduledLocalNotifications method of UIApplication will return an NSArray of all notifications scheduled by the current app. We just index into this array and grab each notification.

Finally, we are displaying the alertBody (text that displays when the notification fires) and the fireDate (date and time when the notification will display) in the tableview cell.

Step 4: Scheduling Notifications
Update your .m file to contain the following code.


- (IBAction) scheduleAlarm:(id) sender {
[eventText resignFirstResponder];

NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];

// Get the current date
NSDate *pickerDate = [self.datePicker date];

// Break the date up into components
NSDateComponents *dateComponents = [calendar components:( NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit )
fromDate:pickerDate];
NSDateComponents *timeComponents = [calendar components:( NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit )
fromDate:pickerDate];
// Set up the fire time
NSDateComponents *dateComps = [[NSDateComponents alloc] init];
[dateComps setDay:[dateComponents day]];
[dateComps setMonth:[dateComponents month]];
[dateComps setYear:[dateComponents year]];
[dateComps setHour:[timeComponents hour]];
// Notification will fire in one minute
[dateComps setMinute:[timeComponents minute]];
[dateComps setSecond:[timeComponents second]];
NSDate *itemDate = [calendar dateFromComponents:dateComps];
[dateComps release];

UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate = itemDate;
localNotif.timeZone = [NSTimeZone defaultTimeZone];

// Notification details
localNotif.alertBody = [eventText text];
// Set the action button
localNotif.alertAction = @"View";

localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;

// Specify custom data for the notification
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"someValue" forKey:@"someKey"];
localNotif.userInfo = infoDict;

// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];

[self.tableview reloadData];
}


We just use the NSCalendar object to break up the date into components. Note: This demo does not require that we break the date up into components. You could have just as easily fed the date from the date picker into the notification fireDate. The reason that I’m showing you how to break it down is, you may have some sort of custom date logic to work with and this makes things much easier in the future.
Another important bit of code is where we set the alertBody or the notification. In this example we set it to the text that the user entered into the text field. You can set this to whatever you like.
The other thing I want to mention is the infoDict in the code. This dictionary is your chance to associate some additional information with the alert. For example, if you are using this alert in a game like We Rule to notify you when a crop is ready. You might want to set a key and value that contains the id of the crop that has completed. For now, we just set some arbitrary values and you can ignore them if you like.
After actually scheduling the notification, we just reload the tableview to get it to display immediately.

Step 5: Handling Notifications After They Fire
The last piece of this puzzle is determining what to do when a notification fires. Fortunately, this step is very easy and handled inside of the appDelegate. When a notification fires, there are one of two situations. 1. The app is running and 2. The app is not running (or running in the “background”) .

Open up your app delegate .m file and add the following code.


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Override point for customization after application launch.

// Add the view controller's view to the window and display.
[window addSubview:viewController.view];
[window makeKeyAndVisible];

application.applicationIconBadgeNumber = 0;

// Handle launching from a notification
UILocalNotification *localNotif =
[launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif) {
NSString *reminderText = [notification.userInfo
objectForKey:@"someKey"];
NSLog(@"Recieved Notification %@",localNotif);
}

return YES;
}

- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
// Handle the notificaton when the app is running
NSLog(@"Recieved Notification %@",notif);
}


The first thing we see here is the application badge number is getting set to 0. Whenever a notification fires, it will increase the badge count on the application. Next, we handle the case when the application launches from a notification. This happens when the user presses the view button on the notification. For now, we just NSLog the data, but you should handle the notification how you see fit for your app.

Finally, we implement the didReceiveLocalNotification method. This method is required if you want to handle notifications at all in your app. You will see this method fire when the app is running and you receive a local notification. When the app is running, you will not see the UIAlertView show up with the notification data. Also keep a note the method - (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
is only called upon when the application is not running and if the application is running in background or foreground, only this methhod gets called: - (void)application:(UIApplication *)application
didReceiveLocalNotification:(UILocalNotification *)notification


And there you have it! The complete lifecycle of a local notification.