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?
Asked
Active
Viewed 1,864 times
3
-
another related post: http://stackoverflow.com/questions/465956/caching-the-struct-object – bryanmac Oct 15 '11 at 00:35
1 Answers
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
-
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