gpt4 book ai didi

cocoa - 使用 NSCoder 编码 CGPoint 结构

转载 作者:行者123 更新时间:2023-12-03 16:02:29 26 4
gpt4 key购买 nike

如何使用 NSCoder 编码和解码 CGPoint 结构?

最佳答案

编码:

CGPoint point = /* point from somewhere */
NSValue *pointValue = [NSValue value:&point withObjCType:@encode(CGPoint)];
[coder encodeObject:pointValue forKey:@"point"];

解码:

NSValue *decodedValue = [decoder decodeObjectForKey:@"point"];
CGPoint point;
[decodedValue getValue:&point];

关于cocoa - 使用 NSCoder 编码 CGPoint 结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/448173/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com