0

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, 265, 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?

Krishnabhadra
  • 34,169
  • 30
  • 118
  • 167
hgpl
  • 869
  • 4
  • 11
  • 20

3 Answers3

2

wrap the CG structures in NSValue classes and add to array .. see the answer to this question...

Community
  • 1
  • 1
Krishnabhadra
  • 34,169
  • 30
  • 118
  • 167
0

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)

shahil
  • 941
  • 9
  • 20
0

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.