I’m trying to instantiate UiAlertView like this:
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Error"
message:@"Incorrect login or password."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
It’s after I get response from server that session expired. App throws me back to login screen then. And then I’m trying to log in with incorrect data, but alert won’t show. Instead it throws something like this:
Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed:
0 libobjc.A.dylib 0x33aa15b0 objc_msgSend + 16
1 UIKit 0x3a39a370 -[UILabel _setText:] + 92
2 UIKit 0x3a4e6648 -[UIAlertView
initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:] + 64
3 MY APP 0x00039c7e 0x34000 + 23678
4 MY APP 0x0005f784 0x34000 + 178052
5 MY APP 0x000756be 0x34000 + 267966
6 Foundation 0x347d28e8 __NSThreadPerformPerform + 456
7 CoreFoundation 0x32bbd680
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
8 CoreFoundation 0x32bbcee4 __CFRunLoopDoSources0 + 208
9 CoreFoundation 0x32bbbcb2 __CFRunLoopRun + 642
10 CoreFoundation 0x32b2eeb8 CFRunLoopRunSpecific + 352
11 CoreFoundation 0x32b2ed44 CFRunLoopRunInMode + 100
12 GraphicsServices 0x3a92c2e6 GSEventRunModal + 70
13 UIKit 0x3a3ea2f4 UIApplicationMain + 1116
14 MY APP 0x0003527e 0x34000 + 4734
15 MY APP 0x000351dc 0x34000 + 4572
Is it something with allocating strings created with @ or what?
EDIT:
I’m adding some more code due to request. I don’t think server response function is relevant, since it just executex logOut method. By the way, the whole code I’m posting is placed in AppDelegate
- (void) logout
{
isLogged = NO;
currentUser = nil;
[self createNotLoggedIn];
}
Then create notLoggedIn method creates UIViewController for login form.
-(void) createNotLoggedIn
{
UIViewController *loginViewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
//UINavigationControllers are created here... stripped
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.delegate = self;
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navLoginViewController, navGrafikLekarzyViewController, navPlacowkiViewController, navWiecejViewController, nil];
[self.window addSubview:self.tabBarController.view];
[self.window makeKeyAndVisible];
}
logOut and createNotLoggedIn are placed in AppDelegate
I moved the code that is showing AlertDialog to AppDelegate when the ViewController is created and it works