3

I want to make a NSMutableArray and fill it up with rectangles created with, say, NSRectMake. But the array only allows objects. What should I do to save the NSRects in an array?

jscs
  • 63,694
  • 13
  • 151
  • 195
Saturn
  • 17,888
  • 49
  • 145
  • 271

1 Answers1

13

Use NSValue that's especially designed for that stuff. In your case, use valueWithRect:

Everything is explained here in Apple's corresponding Programming Guide.

AliSoftware
  • 32,623
  • 6
  • 82
  • 77
  • 7
    If everyone just read the manuals, stackoverflow but not exist. – ott-- Oct 15 '11 at 00:37
  • 3
    ?! I was just giving a pointer to where in the doc was hidden this information (because I actually know that not everyone knows how to search the doc, thus the link to help them find the info) so I don't really understand the comment above o_O – AliSoftware Aug 27 '13 at 15:27
  • @ott Odd that you would choose to comment on a Q&A site just to say, in so many words, "you wouldn't need this site if you RTFM." The problem with RTFM is there is a LOT of FM to R and sometimes people just need the right terminology (even if just a class name) to search. If SO bothers you, don't participate. – Joshua Nozzi Jul 22 '14 at 14:06
  • @LyricalPanda I don't see anything wrong with AliSoftware's answer since it provided a direct answer to the OP's question and gave a helpful link to the relevant documentation. – Joshua Nozzi Jul 22 '14 at 14:07
  • 1
    @JoshuaNozzi Yeah I didn't mean Ali at all. I think at the time there was another comment with Ott's that was to the effect of 'RTFM' as well that has been since deleted. Ali's answer is correct and extremely helpful. If there wasn't a second comment, then I was just very wrong. – LyricalPanda Jul 22 '14 at 15:15