array with frame size
Can I put frame size in an array object?How?Can Anybody help me in this matter?
NSArray * framesize = [[NSArray alloc] initWithObjects:
[CGRectMake(470, 209, 97,100)],
[CGRectMake(484, 258, 50, 12)],
[CGRectMake(479, 259, 8, 14)],
[CGRectMake(509, 26开发者_JAVA技巧5, 15, 10)],
[CGRectMake(510, 282, 16, 8)],
[CGRectMake(455, 309, 24, 50)],
[CGRectMake(425, 348, 37, 40)],
[CGRectMake(505, 550, 35, 35)],
[CGRectMake(490, 655, 30, 40)],
[CGRectMake(430, 304, 50, 11)],
[CGRectMake(450, 409, 41, 25)],
[CGRectMake(509, 685, 25, 20)],
nil];
I want to put the frame size like this.Is it possible?
wrap the CG structures in NSValue classes and add to array .. see the answer to this question...
NSArray can only contain subclasses of NSObject, CGRect is a c struct.
You can create a custom subclass of NSObject, add 4 CGFloat properties to it and store instances of it inside your array.
Best way : CGRect rectP[3] = {CGRectMake(75, 290, 75, 80), CGRectMake(64, 179, 90, 112), CGRectMake(166, 182, 90, 98)};
And then to access it :
CGRect frame1 = rectP[1]; // CGRectMake(64, 179, 90, 112)
精彩评论