MVC architecture issue for Mac application

I have a controller class from which I call a method of the model class. Now, from this method of the model class, I want to constantly update the textView object which is the data member of the controller class. I have a method in my controller class to edit this textView. I tried to create a controller object from the model class method and edited the textView. Although I am not getting any errors, I am not displaying any text in the textView. How do I get the class of the class to use the controller class method to display the text continuously .. ?? I am creating a local controller object and referencing 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];
}

      

0


source to share


1 answer


You should learn to use KVO - Key Value Observing - that way you can make the observer do all 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.

+3


source







All Articles