Saturday, April 27, 2013

NSNotification notificationWithName example ios

notificationWithName :object:

Returns a new notification object with a specified name and object.
+ (id)notificationWithName:(NSString *)aName object:(id)anObject
Parameters of [NSNotification notificationWithName]
aName
The name for the new notification. May not be nil.
anObject
The object for the new notification.
Example of [NSNotification notificationWithName]

    NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:
                                              anItemID, @"ItemID",
                                              [NSString stringWithFormat:@"%i",q], @"Quantity",
                                              [NSString stringWithFormat:@"%@",[NSDate date]], @"BackOrderDate",
                                              [NSString stringWithFormat:@"%@", [NSDate date]],@"ModifiedOn",
                                              nil];
    
    [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:@"InventoryUpdate" object:dict]];