Question about Apple's updated Sketch program

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

  1. mdeh macrumors 6502

    Jan 3, 2009
    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:
    - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError {
    ....set up stuff.......
     [self setGraphics:graphics]; 

    Which calls:

    - (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

    - (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

    - (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