发送消息:
NSString *firstName = @"wu";
NSString *lastName = @"jin lang";
NSString *fullName = [firstName stringByAppendingString:lastName];
NSArray *objects = [[NSArray alloc] initWithObjects:
firstName,
lastName,
fullName,
nil];
NSArray *keys = [[NSArray alloc] initWithObjects:
ResultOfAppendingTwoStringFirstStringInfoKey,
ResultOfAppendingTwoStringSecondStringInfoKey,
ResultOfAppendingTwoStringResultStringInfoKey,
nil];
NSDictionary *userInfo = [[NSDictionary alloc] initWithObjects:objects
forKeys:keys];
NSNotification *notificationObject = [NSNotification notificationWithName:(NSString*)ResultOfAppendingTwoStringsNotification
object:self
userInfo:userInfo];
[[NSNotificationCenter defaultCenter] postNotification:notificationObject];
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(appendingIsFinished:)
name:(NSString *)ResultOfAppendingTwoStringsNotification
object:self];
[self broadcastNotification];
return YES;
}
-(void)appendingIsFinished:(NSNotification *)paramNotification
{
NSLog(@"Notification is received.");
NSLog(@"Notification Object=%@",[paramNotification object]);
NSLog(@"Notification User-Info Dict =%@",[paramNotification userInfo]);
}
NSString *firstName = @"wu";
NSString *lastName = @"jin lang";
NSString *fullName = [firstName stringByAppendingString:lastName];
NSArray *objects = [[NSArray alloc] initWithObjects:
firstName,
lastName,
fullName,
nil];
NSArray *keys = [[NSArray alloc] initWithObjects:
ResultOfAppendingTwoStringFirstStringInfoKey,
ResultOfAppendingTwoStringSecondStringInfoKey,
ResultOfAppendingTwoStringResultStringInfoKey,
nil];
NSDictionary *userInfo = [[NSDictionary alloc] initWithObjects:objects
forKeys:keys];
NSNotification *notificationObject = [NSNotification notificationWithName:(NSString*)ResultOfAppendingTwoStringsNotification
object:self
userInfo:userInfo];
[[NSNotificationCenter defaultCenter] postNotification:notificationObject];
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(appendingIsFinished:)
name:(NSString *)ResultOfAppendingTwoStringsNotification
object:self];
[self broadcastNotification];
return YES;
}
-(void)appendingIsFinished:(NSNotification *)paramNotification
{
NSLog(@"Notification is received.");
NSLog(@"Notification Object=%@",[paramNotification object]);
NSLog(@"Notification User-Info Dict =%@",[paramNotification userInfo]);
}