To catch this problem you'll have to put break points in all callback methods.
The problem is simple, the code is trying to access memory it cant find.
Finding that line of code is harder because the callbacks are not called sequentially.
- Add more break points
- Add more NSLog(..)
- Consider catching exceptions (see http://stackoverflow.com/questions/324284/how-to-throw-an-exception-in-objective-c-cocoa/324301)
Output form the console:
Attaching to program: `/Users/rjstelling/Library/Application Support/iPhone Simulator/User/Applications/C04A40BB-1D98-402E-BBEF-37E6FB860089/TwoViewApp.app/TwoViewApp', process 24032.
Re-enabling shared library breakpoint 1
2009-04-16 16:16:45.830 TwoViewApp[24032:20b] stream event 1
2009-04-16 16:16:45.831 TwoViewApp[24032:20b] on input stream
2009-04-16 16:16:45.831 TwoViewApp[24032:20b] stream event 1
2009-04-16 16:16:45.832 TwoViewApp[24032:20b] on output stream
2009-04-16 16:16:45.832 TwoViewApp[24032:20b] stream event 4
2009-04-16 16:16:45.832 TwoViewApp[24032:20b] on output stream
2009-04-16 16:16:45.833 TwoViewApp[24032:20b] stream has space open
(gdb) continue
2009-04-16 16:17:06.405 TwoViewApp[24032:20b] We made it - ok!
2009-04-16 16:17:06.406 TwoViewApp[24032:20b] stream event 2
2009-04-16 16:17:06.406 TwoViewApp[24032:20b] on input stream
2009-04-16 16:17:06.407 TwoViewApp[24032:20b] Processing: +OK CONN PinkNotes® Plus Master v5.00.26 Beta (v4 compatible)
:tPNPStr
2009-04-16 16:17:06.407 TwoViewApp[24032:20b] SendData= USER (null):tPNPStr
Current language: auto; currently objective-c
Program received signal: “EXC_BAD_ACCESS”.
(gdb)
The problem occurs some where in or after ProcessData
which is a callback I think. Try and put a break point around line 157 in TwoViewAppAppDelegate.m
It's not that line that is causing the EXC_BAD_ACCESS
if you add:
else
{
NSLog(@"We made it - ok!");
}
To the if() statement you can see it passes over the if ( ![sendData isEqualToString:@"-"] ){...}
The error occurs when you return form the method call.
Ok form you comments this might help:
If you create strings using @"My string"
the compiler will map these to he same memory if they have the same content, i.e.:
NSString *var1 = @"string1";
NSString *anotherstring = @"string1";
NSString *morestringivars = @"string1";
Will all point at the same memory space.
This may help, but I'm not sure how? Maybe you can post more code so I can run it on my set up.
Remember an auto release pool is created at the start of the event cycle on the iPhone.
Therefore it is a good idea to call autorelease on sendData as soon as you assign it to the ivar.
...
[sendData autorelease];
...