hidayat
hidayat

Reputation: 9753

objective c, nsstring to nsarray

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 getting out the values to four NSInteger?

Upvotes: 0

Views: 401

Answers (1)

Joost
Joost

Reputation: 10413

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

Upvotes: 5

Related Questions