Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS local notification: I would like to execute a function upon reentering the app via local notificaion
    primarykey
    data
    text
    <p>I am new to iOS programming, as well as working with XCode 4.6, and am trying to build a local notification feature that will execute a function upon reentering the app.Basically I would like to change the text in some of the labels and add some sound upon reentering the app. I thought I was on the right track, but only some parts of my code work when reentering the app via local notification. </p> <p>First I added this function to my AppDelegate: </p> <pre><code>-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{ NSLog(@"test1"); //this traces successfully myAppViewController * controller = [myAppViewController alloc]; [controller doSomething]; //calling a function in my myAppViewController.m } </code></pre> <p>I thought I had figured it out, but now only the NSLog works in my function in myAppViewController.m: </p> <pre><code>-(void)doSomething{ NSLog(@"do something"); //traces successfully self.notificationTime.text=@"something else"; //nothing happens here, it works in other functions but not here [self doSomethingElse]; //calling another function from this function for further testing } </code></pre> <p>The next function is called.... </p> <pre><code>-(void)doSomethingElse{ NSLog(@"do something else"); //this works //this whole thing doesn't work -- no sound -- NSURL* url = [[NSBundle mainBundle] URLForResource:@"cash" withExtension:@"mp3"]; NSAssert(url, @"URL is valid."); self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil]; [self.player prepareToPlay]; [self.player play]; //this doesn't work again self.notificationTime.text=@"something else"; } </code></pre> <p>I was hoping to get some general advice here and it would be much appreciated. If anyone knows a complete different way of solving the problem, that would be great as well!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload