There is no need to contact me directly :-)
NSString variables are pointers (which can be seen by noticing *). Pointers are integers specifying address in memory where something is stored. You can have same strings stored on different locations in memory. Comparing pointers compares the addresses, not the contents. Regards,
Ivan Vučica via phone Thank you . There was little mistake in the attached code that you spotted i .e while(word2!=Quit) so sorry for that. But still i am not getting that why it is not working without using isEqualToStrind method
On Sun, Jan 30, 2011 at 10:21 PM, Ivan Vučica <ivucica@gmail.com> wrote:
Also, don't forget you can get a constant string instance like this: @"Quit"
So:
while(![@"Quit" isEqualToString:word2])
or while(![word2 isEqualToString:@"Quit"])Regards,
Ivan Vučica via phone
You can't compare strings with "==", use "while([Quit isEqualToString: word2] == NO)" instead. In order for that to work, you'll need to setup word2 before comparing it, too. So either set it to nil first or use a do-while loop (probably what you want here, anyway).
Stef On Sat, Jan 29, 2011 at 9:03 AM, Parag Deshpande <parag.deshpande@studioapp.com> wrote:
Hi ,
i am trying to work with NSString object.The .m(source code) file is attached with this mail. Following is the description of my program.
I want to scan the NSString object for that i declare a char array and use stringWithCstring:arg encoding:NSASCIIStringEncoding scan is suucessful but my problem is in
while loop the condition of while i.e while(word2!=Quit) is not running .I mean when i enter "quit" through according logic it should exit while loop and from program. But it enter in endless loop .Please do write where am i went wrong.
Thank you.
_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep
|