iOS KVO 通过change值获取 CGPoint 的坐标点

http://lists.apple.com/archives/cocoa-dev/2010/Apr/msg00106.html

Thanks

pointValue didn't work on iPhone OS but CGPointValue did, luckily, as that's the one I needed. That seems to be a UIKit extension. I've switched to that.

was my original method (apart from being clunky) wrong? It did work.


On 03-Apr-2010, at 10:43 PM, Kiel Gillard wrote:

> On 04/04/2010, at 1:40 AM, Roland King wrote:
>
>> I have a property which is a CGPoint and I'm observing it. I didn't really know what to expect in the change dictionary (I have NSKeyValueObservingOld as the observation flags) so I stuck in a breakpoint and went looking. After messing about in the debugger when the property was changed I found the old value was an NSConcreteValue and the following code appears to work to extract the CGPoint from it
>>
>> 	CGPoint oldPoint;
>> 	id oldValue = [ change valueForKey:NSKeyValueChangeOld ];
>> 	[ (NSValue*)oldValue getValue:&oldPoint ]
>>
>> Is this correct? I've failed to find anything much in the KVO documentation about CGPoint or how I should expect to receive structs or other primitives.
>
> In the case of NSPoint/CGPoint:
>
> CGPoint oldPoint = [oldValue pointValue];
>
>> This is iPhone OS (incase that makes a difference). _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>


//            id newValue = [ change valueForKey:NSKeyValueChangeNewKey ];

//            

//             [ (NSValue*)newValue getValue:&newPoint ];

//            

//            NSLog(@"the point is %@", NSStringFromCGPoint(newPoint));

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值