- (void)incomingNotification:(NSNotification *)notification
{
NSValue *pointAsObject = [notification object];
NSLog (@"Successfully received the test notification %f",pointAsObject.CGPointValue.y);
}
Pass CGPoint in Notification of iOS
문제
I want to send CGpoint to my maincontroller class. So I am using Notification to send cgpoint but I dont know how to extract from cgpoint from notification at receiver. I only get 0.00 on my log output.
Here is my code.
AT sender:
NSValue *pointAsObject =[NSValue valueWithCGPoint:CGPointMake(touchDetectingView.lastTouchPosition.x, touchDetectingView.lastTouchPosition.y)];
[[NSNotificationCenter defaultCenter] postNotificationName: @"swap" object:pointAsObject];
AT receiver Header file:
- (void)incomingNotification:(NSNotification *)notification;
At receiver M file
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(incomingNotification:) name:@"swap" object:nil];
- (void)incomingNotification:(NSNotification *)notification
{
NSValue *pointAsObject = [[notification userInfo] valueForKey:@"swap"];
NSLog (@"Successfully received the test notification %f",pointAsObject.CGPointValue.y);
}
But I only get 0.00 OUTPUT ..
해결책
제휴하지 않습니다 StackOverflow