Help, I'm deperate..i can't continue my app because of this:
I have setup one message between 2 of my cocoa objective-c clases, the main appdelegate is messaging a view through NSNotificationCenter the view receives indeed the notification but somehow it can't update the controls visible on the view.. it's like it can't find the proper instance or something.
here's my code: mainapp (where the appdelegate messages my view):
helloKey = @"0";
helloString = @"mymessage";
values = [NSMutableDictionary dictionaryWithObject:helloString forKey:helloKey];
[[NSNotificationCenter defaultCenter] postNotificationName:@"NewMessageNotification" object:self userInfo:values];
the function is defined in myuiviewcontoler
- (void)NewMessageNotification:(NSNotification *)notification
{
// key associated with string "Hello String"
helloKey = @"0";
// [notificaiton userInfo] returns "values"
helloFromMain = [[notification userInfo] objectForKey:helloKey];
NSLog(@"newmess=%@",helloFromMain; //this outputs mymessage , perfect right?? not quite..here's the problem
//then if I'm trying to update something visible ..it won't do IT!!!! :( :(
//tested with the debugger and it reaches this line...when the messaging occurs
[self.mybutton setTitle:@"sdsdsdasd" forState:UIControlStateNormal];
//this won't work, not it will give an error!!!
}
So what could it be the problem? nothing that is visible can be modified programaticaly when using this, and I kid of need that..
If I do a IBAction and assign it to a button of this view and do the same : [self.mybutton setTitle:@"sdsdsdasd" forState:UIControlStateNormal]; it will update my display without no problem... modifying the title...
So what's the difference between the function that is called by the NSnotificationcenter and a function that belongs to the same view...
I tried to see the address of the self variable in both cases,, it results to be the same... so ..basically uses the same pointer right?
still it doesn't work...
I've put another post back a few days ago..but no-one answered Programatically created labels and images don't show on screen