Search code examples
iosmacosxcode5cgrect

no known class method for selector valueWithCGRect


I'm creating mac application to create a pList file with coordinates for views to be use in iPhone/iPad but I'm getting this error "no known class method for selector valueWithCGRect".

Here is my code:

NSMutableArray *locations = [NSMutableArray new];
[locations addObject:[NSValue valueWithCGRect:CGRectMake(50,50,280,323)]];

Any of you knows how can I fix this or if is a work around this to fix my mac app.

I'll really appreciate you help.


Solution

  • On Mac OS there's +[NSValue valueWithRect:]. It takes an NSRect but on 64 bit that's just a typedef'd CGRect.

    Bear in mind that you can't put arbitrary NSValues into a plist.