Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

int3rc3pt0r

macrumors newbie
Original poster
Feb 9, 2010
9
0
Hey Guys ,

I am totally new to iPhone programming ..
So please don't be hard on me :p

Ok here is the problem

AdditionViewController.h
Code:
#import <UIKit/UIKit.h>

@interface AdditionViewController : UIViewController 
{
	IBOutlet UITextField *Number1;
	IBOutlet UITextField *Number2;
	IBOutlet UITextField *SumAnswer;
}

@property (retain, nonatomic) UITextField *Number1;
@property (retain, nonatomic) UITextField *Number2;
@property (retain, nonatomic) UITextField *SumAnswer;
-(IBAction)buttonPressed1:(id)sender;

@end


AdditionViewController.m
Code:
#import "AdditionViewController.h"

@implementation AdditionViewController
@synthesize Number1;
@synthesize Number2;
@synthesize SumAnswer;


-(IBAction)buttonPressed1:(id)sender
{
	SumAnswer.text = Number1.text + Number2.text; 
       // I want the above line to be edited so that I can get the addition
         of both the numbers in the 3rd Text Field 
}

-
-
-
-
-
@end

I am really new to iPhone programming .. I am trying to understand how
NSString can be used here .. But I am finding it a bit complicated .


If someone please tell me what the code should be ... It will be a great help .
I have to submit a mini project to my school asap .

Thanking You ,
int3rc3pt0r
 
You say you're not but it certainly looks that way. The code you're looking for can be found, with some adjustments, in those threads. Don't expect us to do your homework for you.

:( .. Ok .. I will try that ...
If I get any error I will post it here ...
Thanks ...
 
So how am I supposed to do it without NSString ??

You'll need to convert the NSString objects into something you can do maths on. The documentation or the threads linked above will help you. I'm certainly not about to tell you: learning to program is not copy/pasting from what others do, it's about understanding what is happening, building a mental model of how the system works and how your code fits into that. Personally I'd suggest learning plain, basic C as that will teach you a lot about how the machine works. You might actually then understand why @"10"+@"10" doesn't result in @"20". If Objective-C supported operator overloading (it doesn't) it might result in @"1010"...
 
Hey thankx for the guidance guys ...
I will go ahead with links ... I got the picture now ..thank a ton

Thankx
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.