0

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.

B.T.
  • 41
  • 7
  • I'm not sure, but step 1 would probably be to initialize those objects you're allocating, by calling `init` or whatever the designated initializer is. – Tom Harrington Dec 27 '16 at 21:23
  • **self.MyBridge = [[MyAppProxy alloc] init];** doesn't change the result. – B.T. Dec 27 '16 at 22:01
  • Have you tried putting breakpoints on `thisB` and on the places it is called? If so what did they show? If not then do so and step from the call into the method and through it. (After changing all those `alloc`'s to `new` or `alloc`/`init` as per previous comments.) – CRD Dec 28 '16 at 17:50
  • `MyAppProxy` connects to a device via bluetooth. The `new` and `init` don't work for me, because when `MyAppProxy` is re-initialized it zeroes out all the previously set variables and loses the connection. `thisA` and `thisB` call setters to update the activity variable: *1 = start* and *2 = stop*. As for breakpoints, my app is built in Alloy. When I open the project and build it within Xcode, it breaks before I get to the screen I need to test on because it can't find any of the image files for navigation. Because of this, I can't seem to use breakpoints. Ugh. – B.T. Dec 29 '16 at 17:43

0 Answers0