Manqabat In Praise Of Great Luminaries Aala Hazrat RadiAllahu Anhu, Mufti E Aazam RadiAllahu Anhu & Huzur TaajushSharia

Markaze Ahle Sunnat

Markaze Ahle Sunnat

Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza

Jo Sunniyat ki Shaan hai, jo Qaum ka Imaam hai
Nabi ka jo Ghulam hai, Raza usi ka naam
Jo Razviyoun ki Shaan hai, jo Chishtiyoun ki Aan hai
Wo Qaadiri pathaan hai, Raza usi ka naam hai

Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza

Naqi ka pyara Laad’la, jo Ilm ka pahadd hai
Jo najdiyoun ke waaste, tou Sher ki dahadd hai
Wahabi jis’se dargaye, bahot se hi sudhar gaye
Ye jiska Faize aam hai, Raza usi ka naam hai

Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza

Naseeb waale dekhten hain qwaab mein Huzur ko
Magar kisine jaagte may dekha Haqq ke Noor ko
Hai ayesa koun dosto? batata hoon suno suno
Wo Ishq ka Imaam hai, Raza usi ka naam hai

Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza

Raza ke baad Mustafa Raza hamein ataa huwe
Jinhone har mureed ko milaya Ghause Paak se
Abb ayesa Peer hai kahan ? siwaye Azhari Miyaan
Diya hamein Inaam hai Raza usi ka naam hai

Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza

Ya Rubb Janabe Muftiye Aazam ki khayr ho
Unse hamare dard ka darma hai aaj bhi
Ya Rubb hamare Hazrate Akhtar ki khayr ho
Jinse Raza O Noori ka faizaan hai aaj bhi

Raza ke baad Mustafa Raza ka Darya dekhiye
Hamare Pyaare Azhari Miyan ka Jalwa dekhiye
Haram mein Rutba pagaye, Zamane mein jo chagaye
Ye jiska Faize aam hai, Raza usi ka naam hai

Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza

Deen O Dunya ki hai isme hi behtari,
Dosto thaamlo Daamane Azhari
Naaz jinpar kare aaj khud rehbari
Ayesa Peer E Tareeqat salamat rahe
Main rahun na rahun iss jahan mein magar
Mera Taaj E Shariat salamat rahe

Raza ke baad Mustafa Raza ka Darya dekhiye
Hamare pyare Azhari Miyan ka jalwa dekhiye
Haram mein Rutba pagaye, Zamane mein jo chagaye
Ye jiska Faize aam hai, Raza usi ka naam hai

Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza

Raza se miloge tou khill jaoge
Raza se jaloge tou jall jaoge
Ahmed Raza ka taaza gulistaan hai aaj bhi
khursheed Ilm unka darkhshaan hai aaj bhi
Tum kya gaye ke raunaqe mehfil chaligayi
Shero adab ki zulf pareshaan hai aaj bhi
Baade wisaal Ishq E Nabi kam nahi huwa
Roohe Raza Huzur pe qurbaan hai aaj bhi
Subb unse jalnewaloun ke gul hogaye charagh
Ahmed Raza ki sham’ma firozaan hai aaj bhi

Raza se jalne waaloun ke diye Naeem bujhgaye
Jo Maslak E Raza se aur Salam se ulajh gaye

Nicha karne ko kitne ade rehgaye
Aala Hazrat bade thay bade rehgaye

Raza se jalne waaloun ke diye Naeem bujhgaye
Jo Maslak E Raza se aur Salam se ulajh gaye
Ye ayesa ek Salam hai, Zamane mein jo aam hai
Ke jiska ye Salam hai, Raza usi ka naam hai

Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza

Roze Mehshar agar mujhse puche Khuda
Bol Aale Rasul tu laya hai kya
Arz kardunga laya hoon Ahmed Raza
Ya khuda ye amaanat salamat rahe

Kaha Raza ke Peer ne, Jahaan ke Dastageer ne
Waliye BeNazeer ne, ke Peeroun ke bhi Peer ne
Jo puchega agar Khuda, ke tohfa saath laaye kya ?
Kahega Aale Mustafa, Raza Raza Raza Raza

Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza

Wo ismail dehelwi, sharrefeli thanwi
Wo qaasime nanotwi, wo kawwe wala molvi
Sabhi ka band natqa qalam se jissne kardiya
Wo kaun hai ? wahi tou hai, Raza Raza Raza Raza

Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza
Raza Raza Raza Raza Raza Raza Raza Raza

NSNotificationCenter or Key Value Observer, Which way to go ? (Part 1)

Fork IN The Road Y

Many a times we have more than one choice to implement a task, this is the case in my current project. There are various filters to change, I had to observe the change and load appropriate data. This can be achieved with both NSNotificationCenter and KVO technique offered in cocoa.

The question “NSNotificationCenter or Key Value Observer ?” araises here. To choose among these solutions we have to investigate which one is better fit for given scenario.

Lets take a look at definitions of both as provided by Apple documents,

NSNotificationCenter

An NSNotificationCenter object
(or simply, notification center) provides a mechanism for broadcasting information within a program. An NSNotificationCenter object is essentially a notification dispatch table.

Objects register with a notification center to receive notifications (NSNotification objects) using the
addObserver:selector:name:object:
or
addObserverForName:object:queue:usingBlock: methods. Each invocation of this method specifies a set of notifications. Therefore, objects may register as observers of different notification sets by calling these methods several times.

Each running Cocoa program has a default notification center. You typically don’t create your own. An NSNotificationCenter object can deliver notifications only within a single program.

KVO

Key-value observing provides a mechanism that allows objects to be notified of changes to specific properties of other objects. It is particularly useful for communication between model and controller layers in an application. (In OS X, the controller layer binding technology relies heavily on key-value observing.) A controller object typically observes properties of model objects, and a view object observes properties of model objects through a controller. In addition, however, a model object may observe other model objects (usually to determine when a dependent value changes) or even itself (again to determine when a dependent value changes).

You can observe properties including simple attributes, to-one relationships, and to-many relationships. Observers of to-many relationships are informed of the type of change made—as well as which objects are involved in the change.

From the definitions provided above they are very similar to each other but however we can conclude these differentiating points,

  1. NSNotificationCenter actually involves three entities Observed Object, Observing Object + NotificationCenter itself, whereas KVO just involves Observed Object  and Observing Object. So NSNotificationCenter approach is little HEAVY WEIGTH .
  2. As KVO is direct interaction between two objects is little faster than NSNotificationCenter, As NSNotificationCenter has to trigger the change propagate to Observing object.
  3. NSNotificationCenter is more flexible as its more granular (Notifies before the change is about to occur, Notifies when change occurs, Notifies after change occurs ) than KVO.

My goal was “Any change in filter value should be immediately notified”.

As Performance was very critical requirement, and I did not need more fine-grained notifications, guess which way I took ?

Yes you are right, Obviously its KVO route.

Eager to know the how I implemented it ? Watch out this space, more coming up with sample code 🙂

Thanks for taking your time to read it. 🙂 Let me know if you have any questions regarding this.

NSNotificationCenter or Key Value Observer, Which way to go ? part2

Let's Code

Hi Mates,

This is continuation of part1, if you haven’t read it yet please read it before jumping to this.

Hope you have understood how NSNotificationCenter and KVO differ from each other. In this post we will go deeper into implementation details.

First lets see how to implement notification logic through NSNotificationCenter.

For better readability lets define the notifications we are interested to subscribe.

#define GEOGRAPHY_CHANGED @"geography changed"
#define MARKET_CHANGED @"market changed"
#define METRIC_CHANGED @"metric changed"

Once we have defined the notifications lets ask the NSNotificationCenter to watch for the changes using this api provided by NSNotificaionCenter,

- (void)addObserver:(id)notificationObserver selector:(SEL)notificationSelector name:(NSString *)notificationName object:(id)notificationSender

Lets understand what all parameters it excepts,

  • notficationObserver : The object which is interested to receive notifications.
  • notificationSelector : The subscribed objects method which will handle the notifications once received, this can different for different notifications.
  • notificationName : The notification
  • notificationSender : You can restrict the notification to particular senderObject, if you pass nil here Notification Center ignores who the sender is.

When we are ready to receive notifications we call this method,

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationHandler:) name:GEOGRAPHY_CHANGED object:nil];

To post notification we can use these apis,

- (void)postNotification:(NSNotification *)notification
or 
- (void)postNotificationName:(NSString *)notificationName object:(id)notificationSender
or
- (void)postNotificationName:(NSString *)notificationName object:(id)notificationSender userInfo:(NSDictionary *)userInfo

This method should be called when we want to notify the change to the observer,

[[NSNotificationCenter defaultCenter] postNotificationName:GEOGRAPHY_CHANGED];

//Use this if Observer object wants to know who has notified...
[[NSNotificationCenter defaultCenter] postNotificationName:GEOGRAPHY_CHANGED object:notifierObject];

//Use this if Observer object needs additional info...
[[NSNotificationCenter defaultCenter] postNotificationName:GEOGRAPHY_CHANGED object:notifierObject userInfo:additionalInfo];

The notification handler will be invoked every time notification is posted, sample notification handler will look like this,

-(void)notificationHandler:(NSNotification)notif
{
//Use your own logic here to handle the notification....
    NSLog(@"Notification Name : %@",notif.name);
    NSLog(@"Notifier Object : %@",notif.object);
    NSLog(@"Notifier Object : %@",notif.userInfo);
}

Thats all about registering for notifications, posting and handling them. Once we no longer need to receive notifications we can remove the observer by using this api,

- (void)removeObserver:(id)notificationObserver

Pass the observerObject to this api as follows,

[[NSNotificationCenter defaultCenter] removeObserver:observerObject];

This will unsubscribe the observerObject and any notifications posted will not be delivered to observerObject.

Its time to see how KVO works, so here instead of defining the notification’s using #defs we create a model object something like this,

//Interface...
@interface AstraZenecaDataFilterModel : NSObject
    @property (nonatomic, copy) NSString *geography;
    @property (nonatomic, copy) NSString *market;
    @property (nonatomic, copy) NSString *metric;
@end

//Implementation...
@implementation AstraZenecaDataFilterModel
   @synthesize geography = _geography;
   @synthesize market = _market;
   @synthesize metric = _metric;
@end

This data model acts as userInfo parameter of NotificationCenter as well as it’s object will be used to register for any change in its properties values.

We use this api provided by NSObject to register for notification,

- (void)addObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options context:(void *)context;

The parameters it accepts are,

  • observer : The object which is interested to receive notifications.
  • keyPath : The property of the data model to observer.
  • options : A combination of the NSKeyValueObservingOptions values. The options determine what is included in observer notifications and when they’re sent.
  • context : Arbitrary data that is passed to anObserverin observeValueForKeyPath:ofObject:change:context:.

Lets register our data model object for notifications,

//Initialize it...
AstraZenecaDataFilterModel *observedObject = ...;
...
[observedObject addObserver:observingObject forKeyPath:@"geography" options:(NSKeyValueObservingOptionNew |NSKeyValueObservingOptionOld) context:NULL];

Now to handle the change notifications observingObject MUST implement the method,

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context;

The parameters it provides as are,

  • keyPath : property of observedObject which has been changed.
  • object : observedObject
  • change : A dictionary that describes the changes that have been made to the value of the property at the key path

Sample implementation of the above method looks like this,

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
     if ([keyPath isEqual:@"geography"] && ![[change valueForKey:@"old"] isEqual:[change valueForKey:@"new"]]) {
          gridData = [self loadSalesData];
     }
}

This method will be invoked whenever there is a change in value of observedObject property. We can inspect what was the old value and what is new value assigned to the property and take appropriate action.

Thats all mates you now know how KVO and NSNotificationCenter works. You can decide which way to go based on the requirement.

Please do write a mail in case you need any clarification.

Thanks for taking your time to read it. Hope you enjoyed the post.