 |
 |
|
 |
01-30-2010, 11:27 PM
|
#1 (permalink)
|
|
Registered Member
Join Date: Jan 2010
Posts: 12
|
hard time debugging an NSString concatenation
if([self checkIfInsideBoard_X:touchLocation.x checkIfInsideBoard_Y:touchLocation.y] == YES) {
//check if there are any highlighted cell in the board, if no sets it to yes to highlight a cell
//get source
if (isActiveCell == NO) {
isActiveCell = YES;
[self getCellFromCoordsX:touchLocation.x coordsY:touchLocation.y];
//save source to sMove string
moveString = [[[NSString stringWithFormat: @"%d", [self getRow:touchLocation.y]] stringByAppendingString:[NSString stringWithFormat: @"%d", [self getColumn:touchLocation.x]]] stringByAppendingString: sBoard[ [self getRow:touchLocation.y] ] [ [self getColumn:touchLocation.x] ] ];
NSLog(@"move string : %@", moveString);
// NSLog(@"filename: %@", [self getPieceFileName:@"A"]);
}
//get destination
else {
isActiveCell = NO;
moveString2 = [NSString stringWithFormat:@"%@_%@", moveString, @"i'm concatenating this string to moveString"];
}
}
i have this code above, and keep getting an error like this: Program received signal: “EXC_BAD_ACCESS”.
warning: Couldn't find minimal bounds for "_sigtramp" - backtraces may be unreliable
i get this error on this line of code: moveString2 = [NSString stringWithFormat:@"%@_%@", moveString, @"i'm concatenating this string to moveString"];
}
it's a simple concatenation of string but i really don't understand why i'm getting this error. can somebody please help me.. thnx in advance.. any help will be appreciated.
|
|
|
01-31-2010, 01:58 AM
|
#2 (permalink)
|
|
Senior Member
iPhone Dev SDK Supporter
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,070
|
You'll get an error if either of the strings you're concatenating get autoreleased before you use them. I'd NSLog moveString and the other string (if it's not really a constant) right before you use them in that line.
I can see that if isActiveCell==YES then moveString won't get assigned a value by this code. If the string it points to isn't valid any more. it'll crash.
|
|
|
02-01-2010, 01:18 PM
|
#3 (permalink)
|
|
Registered Member
Join Date: Dec 2009
Posts: 266
|
Just a tip, you can have more than one field in a format string. e.g., @"Your name is: %@\nYou are %i year old %@."
__________________
@rarindeed
Burstly is the only open and free ad management platform for iPhone app developers.
|
|
|
02-05-2010, 09:28 AM
|
#4 (permalink)
|
|
Registered Member
Join Date: Jan 2010
Posts: 12
|
ahh.. thanks guys.. 
i've solved the problem.. well, at least one of my problems.. thanks for your help..
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 384 |
| 27 members and 357 guests |
| AdamSubach, airsoft808, anonymous@, benoitr007, bensj, Danneman, Duncan C, gtyt38, gustavo7sexton, HemiMG, Jeremy1026, lifeCoder45, maxus182, mox, Ovidius, Paul10, pofak, qilin, raheel, Sega dude, squidboy, timle8n1, ufbobbo, ultrayard077, ZunePod |
| Most users ever online was 965, 06-30-2010 at 04:26 AM. |
» Stats |
Members: 41,860
Threads: 49,768
Posts: 213,052
Top Poster: BrianSlick (3,138)
|
| Welcome to our newest member, gustavo7sexton |
|