NSString * mystring = @"123+456"; NSArray * array = mystring componentsSeparatedByString:@"+"; NSString * str1 = array objectAtIndex:0; //123 NSString * str2 = array objectAtIndex:1; //456.
1 Thanks a lot! It was exactly what I wanted. :) – wOlVeRiNe Sep 20 '11 at 16:07 Consider accepting answers when they solve your problem ;) – ender Sep 20 '11 at 16:13 lol, alryt :) i'll do that – wOlVeRiNe Sep 20 '11 at 16:15 Nice one, chapeau – ender Sep 20 '11 at 16:22.
Found this at NSString tokenize in Objective-C Found this at borkware.com/quickies/one?topic=NSString (useful link): NSString *string = @"oop:ack:bork:greeble:ponies"; NSArray *chunks = string componentsSeparatedByString: @":"; Hope this helps! Adam NSString *string = @"123+456"; NSArray *chunks = string componentsSeparatedByString: @"+"; int res = chunks objectAtIndex:0 intValue+chunks objectAtIndex:1 intValue.
The "objectAtIndex" method was missing, but I think you expected me to figure that out :p, which ofcourse I couldn't as i'm just in the learning phase. Neway, I appreciate your taking valuable time out to think about an answer and also ofc for answering. Thanks.
– wOlVeRiNe Sep 20 '11 at 16:09.
You can separate strings by using NSStrings componentsSeparatedByString: NSString *calculation = @"1235+4362"; NSArray *results = calculation componentsSeparatedByString:@"+"; NSLog(@"Results: %@", results); If you are attempting to implement a calculator you may want to familiarize yourself with Reverse Polish Notation and the Shunting-Yard Algorithm as you will find trying to create a simple calculator will be a bit more challenging than expected..
Thanks a lot for the postfix and algo suggestion. But the thing is that I wanna do it without using any pushing-popping mechanism i. E a stack.
If my efforts don't yield success, i'll definately go with the postfix method :), thanks – wOlVeRiNe Sep 20 '11 at 16:12.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.