views:

76

answers:

1

I am learning objective c and am making some small programs. for my current project i am taking a NSBox and changing it's location based on a random number. How do I change the box's location? With C# it was a simple "box.location = anotherLocation" but I can't figure out how to do this in objective c. Any help would be greatly appreciated.

Thanks.

A: 

To change the location of the NSBox, you have to use the setFrame method:

NSRect frame = [box frame];
frame.origin = NSMakePoint(newX, newY);
[box setFrame:frame];
Laurent Etiemble
You can just do `[box setFrameOrigin:NSMakePoint(newX, newY)]`. No need for an intermediate NSRect.
Chuck
sweet! thanks so much guys.
Merle
@Chuck: Miss that, thx.
Laurent Etiemble