开发者

objective c, nsstring to nsarray

开发者 https://www.devze.com 2023-02-10 03:23 出处:网络
Im new to objective C so I need some help, is there any fast way of converting this string: {{2, 2}, {103, 166}} to an NSArray, or just ge开发者_StackOverflow社区tting out the values to four NSInteger

Im new to objective C so I need some help, is there any fast way of converting this string: {{2, 2}, {103, 166}} to an NSArray, or just ge开发者_StackOverflow社区tting out the values to four NSInteger?


This is the storage format of a CGRect/NSRect. You can easily read it using CGRectFromString/NSRectFromString and then get the values like this:

NSString *string = @"{{2, 2}, {103, 166}}";
CGRect rect = CGRectFromString(string);
CGFloat x = rect.origin.x; // 2
CGFloat y = rect.origin.y; // 2
CGFloat width = rect.size.width; // 103
CGFloat height = rect.size.height; // 166
0

精彩评论

暂无评论...
验证码 换一张
取 消