Converting NSpoint and passing values ​​to CGRectMake

I am getting the point at NSPoint as:

NSPoint: {273,534}

      

I want to transfer 273 and 534 to CGrectMake

.
For example:

viewTwo.frame=CGRectMake(273,534,someValue,someValue)

      

I cannot get the values ​​in this NSpoint

.
I tried to pass it to NsArray and NSDictionary. Nothing works. Pls help

I am using the Po command in the console and found the value I need in NSPoint. But dont know how to convert it.

+3


source to share


4 answers


NSPoint is a type of Mac OS. I don't think this is defined in iOS. On iOS, you can simply pass the NSPoint to the CGPoint:



//Probably not valid in iOS because NSPoint isn't defined, but is shows a variable
NSPoint somePoint = MakePoint(273,534); 

//Cast an NSPoint to a CGPoint in order to get at it values...
viewTwo.frame=CGRectMake(273,534,((CGPoint)somePoint).x,((CGPoint)somePoint).y);

      

+5


source


Suppose you have this:

NSValue *point = [NSValue valueWithCGPoint:CGPointMake(273, 534)];

      

It will output like this to the console:



NSPoint: {273,534}

      

So, you can create CGRect like this

viewTwo.frame=CGRectMake([point CGPointValue].x, [point CGPointValue].y, someValue, someValue);

      

+4


source


Perhaps it:

NSPoint somePoint; 
// Assuming this point got its value from some function.
viewTwo.frame = CGRectMake(somePoint.x, somePoint.y, myWidth, myHeight);

      

0


source


Don't need an import for the framework? Projects created in Xcode 6+ don't have a default precompiled header, so more frame headers need to be imported; although NSPoint should just work fine.

0


source







All Articles