How to repaint 'drawRect' in custom view?

Discussion in 'Mac Programming' started by youngplayer, Jul 2, 2008.

  1. youngplayer macrumors member

    Joined:
    May 16, 2008
    Location:
    Shanghai,China
    #1
    In my opinion, the 'drawRect' function seems like the 'paint' function in java.
    So, is there some some function like 'repaint' which refresh the screen?

    For example,
    -(void) drawRect: (NSRect) rect{
    NSString * str = [otherObject stringToDisplay];
    [str drawAtPoint: originalPoint withAttributes: attributes];
    }

    How can I refresh the screen immediately when the value of [otherObject stringToDisplay] has been changed?
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    You tell the view that it need redrawing via the setNeedsDisplay: method clearly highlighted in the documentation.
     

Share This Page