views:

217

answers:

1

I have a controller class from which I call a method of model class. Now from this model class method I want to update textView object which is a data member of controller class continuously. I have method in the controller class to edit this textView. I tried creating a controller object from the model class method and edited the textView. Although I don't get any errors, but its not displaying the text in the textView. How do I get the model class use controller class method to display text continuously..?? Is it that I am creating a local controller object and referring to its textView instead of the original controller object.

Controller.m file:

- (void) notifyContentHasChanged:(NSInteger) block {
    NSString *str;
    str = [NSString stringWithFormat:@"Block Written Successfully: %d\n", block];
    [data insertText:str];
}

Model.m file:

Controller * c = [[Controller alloc] init];
while (USB_SUCCESS(status)){
    DfuBlockCnt++;
    printf("\nBlocks Written Successfully: %d",DfuBlockCnt);
    [c notifyContentHasChanged:DfuBlockCnt];
}
+3  A: 

You should look into using KVO - Key Value Observing - that way you can have an observer do all of the work for you.

I wonder if your connection to the NSTextView is missing - it won't give you an error if you try to pass a message to a nil object in Objective C.

Matthew Schinckel