Ok, so you want to work with a UILabel in a view, update that data from Smalltalk at any point.

Well first there is a problem

As you know, or didn't know, views can be disgarded from a controller when the view is not visible.
See didReceiveMemoryWarning and viewDidUnload/viewDidLoad

Now the problem is that in Smalltalk you can't quite do (self sharedApplication delegate myViewController view viewWithTag: 42) setText: 'foo' asNSStringUTF8.
and expect sanity, since the view might actually not exist now, even if it did in the past, because it might have been unloaded.

Suggestions for solving this, yet respecting the fact the view can go away are welcome.

However perhaps you have a value holder on your application delegate.
Something like

@interface DummyClassForTextData : NSObject {
NSString *text;
UILabel *label;
}
- (void)setNeedsDisplay;

@property (nonatomic,retain) NSString *text;
@property (nonatomic,assign) UILabel *label;
@end

@implementation DummyClassForTextData
@synthesize text,label;

- (void)setNeedsDisplay {
if (self.label) {
[self.label setNeedsDisplay];
}
}
@end

and you setup the DummyClassForTextData at startup time, then set label to the proper value at viewDidLoad, and to nil at viewDidUnLoad.

In the View you override viewWillAppear: to fetch the text from the DummyClassForTextData as needed.
Although in theory you could set the text from the setText: of the DummyClassForTextData you still have the case where the view does not exist.
But in that case you could alter the viewDidLoad to pickup the text from the DummyClassForTextData instance.

Feedback on the two solutions is welcome
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki