Question about Apple's updated Sketch program

Discussion in 'Mac Programming' started by mdeh, Oct 13, 2009.

  1. macrumors 6502

    Joined:
    Jan 3, 2009
    #1
    Hi All,
    I think this is an easy issue...for those with more knowledge than I :)

    I am puzzled about one of the setters of an NSArray (_graphics) in the document.m file. It clearly assigns any objects that were unarchived ( as the setter is called by:
    Code:
    - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError {
    
    ....set up stuff.......
     [self setGraphics:graphics]; 
    ;

    Which calls:

    Code:
    
    - (void)setGraphics:(NSArray *)graphics {
        unsigned i = [_graphics count];
        while (i-- > 0) {
            [self removeGraphicAtIndex:i];
        }
        i = [graphics count];
        while (i-- > 0) {
            [self insertGraphic:[graphics objectAtIndex:i] atIndex:0];
        }
    }
    
    which calls

    Code:
    - (void)insertGraphic:(SKTGraphic *)graphic atIndex:(unsigned)index {
        [[[self undoManager] prepareWithInvocationTarget:self] removeGraphicAtIndex:index];
        [_graphics insertObject:graphic atIndex:index];
        [graphic setDocument:self];
        [self invalidateGraphic:graphic];
    and the part that I do not get

    Code:
    
    - (void)invalidateGraphic:(SKTGraphic *)graphic {
        NSArray *windowControllers = [self windowControllers];
    
        [windowControllers makeObjectsPerformSelector:@selector(invalidateGraphic:) withObject:graphic];
    }

    I see the general gist, but am lost in the details of the point of the "invalidiateGraphic" call and exactly what it does. If anyone sees the issue, I would gladly like to hear your point of view.
    Thanks kindly in advance
     

Share This Page