Blog

Filtering all blogs posted by "Ali Nour."    Clear filter

Running iPhone Apps in the Background

iPhone OS4 has been introduced with a new important feature which is multitasking.

Multitasking and the ability to run program in the background opened a new development field for iPhone developers, so I just wanted to blog an introduction tutorial to develop an application that runs in background.

When an app According to the iOS Application Programming Guide, if the device doesn't have iPhone OS4 or later versions it will not support multitasking and the application delegate will receive the applicationWillTerminate: message instead of applicationDidEnterBackground: .

I attached a project that demonstrates the multitasking capabilities, find it here .

In The "AppDelegate" class, you will notice the new messages that the application sends to notify the delegate of its foreground/background states.

I added logging message to show the sequence of calling these messages.

In the applicationDidEnterBackground:  message you can perform some tasks to wrap up your work, and the framework only gives you a small amount of time to complete wrapping your work, so I tested that on the simulator and it gave me about 10 seconds to complete my background task until my application is purged from memory.

Also I add 2 alerts to demonstrate the new local notification feature, it's very helpful feature when it comes to alerting the user at a certain time or after a certain duration. The alerts will be registered when the AppDelegate executes applicationDidEnterBackground message.

I tried to keep it simple and quick for you to start working with background feature and local notification feature. For more info please see the reference .

 

Read More

Log to Debug efficiently in Objective-C

Everyone wants to have an effecient logging method that releave him from the stepping debugging.

The following is a macro for debugging showing only in debug mode.

It shows:

  • Current File.
  • Current Function.
  • Current Line.
  • Custom Argments.

#ifdef DEBUG
#   define DLog(fmt, ...) NSLog((@"%s %s [Line %d] " fmt), __FILE__, __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#   define DLog(...) ;
#endif

// ALog always displays output regardless of the DEBUG setting
#define ALog(fmt, ...) NSLog((@"%s %s [Line %d] " fmt), __FILE__, __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);

 

Ex: ALog(@"Hello world") will print:

path/to/LibraryController.m  -[LibraryController awakeFromNib] [Line 364] Hello world

 

Enjoy

Reference: http://stackoverflow.com/questions/969130/nslog-tips-and-tricks

Read More

Useful Chrome extensions for developers4

I have experienced some useful Chrome browser extensions, I hope that they help you.

JSONView for Chrome™

AdBlock 

Bubble Translate

Read Later Fast 

TooManyTabs for Chrome

You can add other useful ones that you have tried.

Read More

Terminal start up Commands Mac OS1

 If you need your terminal to always open on a certain directory or to execute any command every time it starts.

  1. open your terminal.

  2. cd <directory> to /Users/<your user name>

  3. sudo vi .profile

  4. write commands to be executed every time you open your terminal.

I wrote: echo 'بسم الله الرحمن الرحيم'

I hope it helps.

 

Read More

Building Route-Me for iPad4

Route-Me is an open source native slippy map library for the iPhone, it replaces the MapKit framework that comes with iPhone SDK.

Route-Me works with OpenStreetMap, Microsoft VirtualEarth and CloudMade with support to offline browsing, on the other side the MapKit framework is limited to Google Maps and does not support offline browsing. During the development of an iPad application.

Read More