Problems with NSString: initWithCString
Problems with NSString: initWithCString
- Subject: Problems with NSString: initWithCString
- From: Andrew Baldwin <email@hidden>
- Date: Thu, 28 Mar 2002 01:54:32 -0500
A snippet from my code:
searchString = [[NSString alloc] initWithCString:&(aBuffer[2]);
I get the following error when debugging:
"Unable to determine target of Objective-C method call (ignoring):
Error accessing memory address 0x3: Invalid argument"
In gdb, if I type: "print (char*)&(aBuffer[2])" it prints what I expect,
an 88 character long cString... only in the format:
"\371\361\314\270\226\207\363\336\350\343\223\....\000"
Why am I getting this error? searchString is simply an NSString*
previously set to nil and shouldn't have anything to do with this, so
why is there a problem with [[NSString alloc] initWithCString:buffer]? I
get the same error even if I change my code so that I can use [[NSString
alloc] initWithCStringNoCopy:&(aBuffer[2]) length:(bLength - 2)
freeWhenDone:YES].
Sorry if this is very simple and I'm just not seeing the solution,
Andrew
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.