views:

270

answers:

1

Hey,

I ran into a problem. I can't image why that happens, probably you guys can.

I've created a UIBarButtonItem in IB and linked it correctly. A set the property and synthesized it. At the beginning I set the btn disabled (viewWillAppear). Then I try to add an entry to my mysql db:

NSString *URLStr = [NSString stringWithFormat:@"http://www.justfortestingandsoon.com/example.php?entry=%@", myEntry];
URLStr = [URLStr stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSLog(@"URLStr: %@",URLStr);
NSURL *addURL = [NSURL URLWithString:URLStr];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:addURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
            urlConnectionSet = [NSURLConnection connectionWithRequest:urlRequest delegate:self];

In it's "didReceiveData..." I check which value gets returned:

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    NSData *myData;
    myData = data;
    NSString *testString = [[NSString alloc] initWithData:myData encoding:NSASCIIStringEncoding];
    NSLog(@"receivedData: %@", testString);
if ([testString isEqualToString:@"ENABLED"]) {
        self.notificationBtnDeactivate.enabled = YES;
    }
...

I already debugged it. The line self.notificationBtnDeactivate.enabled = YES; gets called but without any noticable changes on the UI.

Any Ideas?

Thanks a lot!

A: 

I have two ideas for this:

  1. the buttons are not correctly referenced from IB, add some NSAssert and check against nil
  2. you doing your UI changes on the wrong thread. Try to use performSelectorOnMainThread:withObject:waitUntilDone:
Tim Büthe