5

I am getting a point in NSPoint as:

NSPoint: {273,534}

I want to pass 273 and 534 into CGrectMake.
For example:

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

I am not able to get the values in that NSpoint.
I tried passing it to NsArray and NSDictionary. Nothing works. Pls help

I use Po command in console and found the value which i need is in NSPoint. But dont know how to convert it

iworld
  • 345
  • 1
  • 4
  • 17

4 Answers4

5

NSPoint is a Mac OS type. I don't think it's defined in iOS. In iOS you can just cast an NSPoint to a 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's values...
viewTwo.frame=CGRectMake(273,534,((CGPoint)somePoint).x,((CGPoint)somePoint).y);
Duncan C
  • 128,072
  • 22
  • 173
  • 272
4

Assume that you have this:

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

It will output like this in console:

NSPoint: {273,534}

So you can create CGRect like this

viewTwo.frame=CGRectMake([point CGPointValue].x, [point CGPointValue].y, someValue, someValue);
Ratha Hin
  • 670
  • 7
  • 13
0

Maybe this:

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

Are you missing an import for the Foundation framework somewhere? In projects created in Xcode 6+, there's no default precompiled header so more framework headers have to be imported manually; although NSPoint should just work fine.

Jannis
  • 99
  • 7
  • 1
    There is no such thing as NSPoint in iOS. – rmaddy Dec 18 '14 at 15:30
  • Correct, but there is on OSX :-). CGPoint, CGRect, etc have NS... equivalents when developing an OSX app. – Jannis Dec 18 '14 at 15:45
  • 1
    The question is tagged iOS. So the answer should be appropriate for iOS. You can't import the header for `NSPoint` in an iOS app. – rmaddy Dec 18 '14 at 15:47
  • @rmaddy must have overlooked that, though he does state that he gets NSPoints from a framework, perhaps the framework in question was meant for OSX? – Jannis Dec 19 '14 at 12:12