Advertise Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

sdkIQ for iPhone
($4.99)

Your First iPhone App
($1.99)

iPhone Code Generator
($9.99)

Dual Matches
($0.99)

Calcuccino Programmers' Calculator
($2.99)

SDKtoday
(free)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-30-2010, 11:27 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 12
Default 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.
rjakecastro is offline   Reply With Quote
Old 01-31-2010, 01:58 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,070
Default

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.
__________________
~~
-- Available Now: Dead Panic, a strategic zombie shooter!(iPhone)
-- New Blog Post: A Simple Observer Pattern for iPhone / Cocoa Games
smasher is offline   Reply With Quote
Old 02-01-2010, 01:18 PM   #3 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 266
Default

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.
rarindeed is offline   Reply With Quote
Old 02-05-2010, 09:28 AM   #4 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 12
Default

ahh.. thanks guys..
i've solved the problem.. well, at least one of my problems.. thanks for your help..
rjakecastro is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


» Advertisements
» Stats
Members: 41,860
Threads: 49,768
Posts: 213,052
Top Poster: BrianSlick (3,138)
Welcome to our newest member, gustavo7sexton
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:52 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0