iOS - alloc called twice with different results

63 views Asked by At

First, I'm bridging Appcelerator with native iOS code and I don't have access to Hyperloop. The following functions exist in the native iOS code. They are compiled as an iOS module and called directly from the Appcelerator code:

MyAppModule.m

-(void)thisA
{
    NSLog(@"***** Started A");
    self.MyBridge = [MyAppProxy alloc];
    [self.MyBridge callThis];
    NSLog(@"***** Ended A");
}

-(void)thisB
{
    NSLog(@"***** Started B");
    self.MyBridge = [MyAppProxy alloc];
    [self.MyBridge callThisOtherThing];
    NSLog(@"***** Ended B");
}

-(void)thisC
{
    NSLog(@"***** Started C");
    self.MyBridge = [MyAppProxy alloc];
    [self.MyBridge callThisOtherThing];  // Does the same thing B does
    NSLog(@"***** Ended C");
}

MyAppProxy.m

-(void)callThis
{
    thisVar = 1;
    NSLog(@"***** thisVar set to 1");
}

-(void)callThisOtherThing
{
    thisVar = 2;
    NSLog(@"***** thisVar set to 2");
}

When I initially call thisA, it works. I see all 3 NSLogs and the expected result occurs. When I initially call thisB, it works. I see all 3 NSLogs and the expected result occurs.

When I call thisA again 5 minutes later, it still works. I see all 3 NSLogs and the expected result occurs. When I call thisB again 5 minutes later, it doesn't execute at all. I don't even see the first NSLog (Started B). If I then call thisC after that, it works just fine. Ugh.

There's ostensibly no difference between thisA and thisB. Yet, one fires multiple times and the other only fires once.

What am I doing wrong? I'm at wits end. Thanks guys.

0

There are 0 answers