I'm going to try to put as much detail as possible in this post because its very important i accomplish this task and i dont know why im getting these strange results. So, here it goes.
I have 5 view controllers/.xib files. I also have appdelegate and a LocationManager singleton class, designed to provide each .h/.m file with location updates. View controller 1, known as WelcomeView, is the delegate for location updates. So it has the didUpdateLocations method in it. It watches for a person to enter a specific area. When this specific area is entered, it tells the person to go to another area to receive a prize of sorts. didUpdateLocations monitors ALL movement, including watching for the person to enter both area 1 and area 2. If the person successfully enters area 1, it's supposed to switch views to TransitionViewController for 3 seconds, then switch to TimerViewController. Here's the code i used to switch:
self.transitionView = [[TransitionViewController alloc] initWithNibName:@"TransitionViewController" bundle:nil];
[self.view addSubview: self.transitionView.view];
then in the transition view controller, i have it sleep for 3 seconds and then switch to timerviewcontroller, like this:
sleep(3);
self.timerView = [[TimerViewController alloc] initWithNibName:@"TimerViewController" bundle:nil];
[self.view addSubview:self.timerView.view];
When i actually enter the area and all of this is supposed to take place, originally it worked like a charm. As it turns out, it only worked when the phone was plugged into the mac and running from Xcode. Now, I've gotten it to the point that it just takes 45 seconds - 1 minute to actually switch to transition, and then when in transition it takes an additional 20 seconds or so before switching to timer. I've tried various things like putting both commands on the main thread, like so:
sleep(3);
[[NSOperationQueue mainQueue] addOperationWithBlock:^ {
NSLog(@"Finished sleeping; switching to timer now.\n");
self.timerView = [[TimerViewController alloc] initWithNibName:@"TimerViewController" bundle:nil];
[self.view addSubview:self.timerView.view];
}];
or putting the transition to timer on a background thread, like this:
[self performSelectorInBackground:@selector(transitionToTimer) withObject:nil];
I'm at a loss. I don't know why this is happening and this job was supposed to be done last week. Any suggestions for me? Anybody?
EDIT
This is the strangest part of it: If i start the app while already inside area 1, it runs through flawlessly. The app does exactly what its supposed to. It's when i walk into the hotspot that it crashes or takes forever to switch views. So if the app is running on the phone FROM Xcode OR im already in the hotspot when it starts, it runs fine. If i run the app independent of xcode and walk into the hotspot, it crashes or it takes over 60 seconds to switch views. It realizes its supposed to switch, it just doesnt do it for 60+ seconds.