Hillegass chapter 18 pg 260 problem and question

Discussion in 'Mac Programming' started by John Baughman, Jul 19, 2009.

  1. macrumors member

    Joined:
    Oct 27, 2003
    #1
    in the SetImage mthod we added...

    Code:
    downPoint = NSZeroPoint;
    currentPoint.x = downPoint.x + imageSize.width;
    currentPoint.y = downPoint.y + imageSize.height;
    Why do we add the width and height to downPoint x and y. downPoint will always be 0/0 so why to why can't you just apply the width and size directly...

    Code:
    downPoint = NSZeroPoint;
    currentPoint.x = imageSize.width;
    currentPoint.y = imageSize.height;
    
    Problem: For some reason I cannot get currentPoint.x to be anything but zero. currntPoint.y gets a value but not currentPoint.x. Result is the image cannot be seen when it is opened. Clicking anywhere immediately makes it visible as a straight vertical line, then you can resize it. The width of my image is 128, so I tried assigning 128 directly and it still does not work.

    Thanks for any help.

    John

    OK, I am wrong. currentPointer.x is getting the set. I was using NSLog to look at the value being set and apparently not doing that correctly. I can see it being set properly to 128 in the debugger.

    Now the question is why doesn't the picture display when first opened?

    I found the bug. I had the height parameter of NSmakeRect maxY=minY instead of maxY-minY.

    Still curious as to why we are adding the height and width of the image to zero to set the points of the current rectangle.
     
  2. macrumors 6502

    Cinder6

    Joined:
    Jul 9, 2009
    #2
    I don't think there's any reason to add them.
     
  3. macrumors 6502

    Joined:
    Feb 7, 2008
    #3
    Would that be the line the author tells you to double check because many people mistype it? I just did that exercise last night and wondered about his comment.
     

Share This Page