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

Nitrex88

macrumors newbie
Original poster
Dec 30, 2007
11
0
Hi, I am fairly new at mac programming, although i have knowledge in many programming languages. I am trying to get into using xcode and to start I thought i would make a calculator with a gui that has buttons to click. The app works fine except for one major problem. Lets say I click the 5 button, the app displays 5 in the above text field, then I can choose an operator, another number such as 7, and display the result in the text field. The problem is that I cant use two digit numbers. If I click 5 and then click 2 to use 52, it wont. It will replace the 5 with the 2. I need a way to use numbers above one digit so when i click 5, it displays 5, and then when i click 2, it displays 52, until I click an operator, in which case it would take the current number in the field and put it in a variable. I am using Xcode 3 in leopard which uses Objective-C 2, if that matters. I dont need sample code if you dont have the time, just an idea of how to do it. Thanks in advance and I hope someone could help
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
I suggest you use an NSString to display the number and only turn it into an NSNumber to perform the actual calculation. Then you can just append the new number to the existing string to display it.
 

Nitrex88

macrumors newbie
Original poster
Dec 30, 2007
11
0
Thanks for the help

Thanks for the sample app. That was just what i was looking for. That was really helpful and now i get it. Thanks a lot.
 

Tardigrade

macrumors newbie
May 16, 2008
2
0
Sandhurst, UK
Hi,

I'm in the same position as the original poster and could do with the sample app for the calculator if its still available (the link no longer works). Don't know where to start at the moment.

Thanks in advance.

Cheers

Jon
 

Nitrex88

macrumors newbie
Original poster
Dec 30, 2007
11
0
Hi,

I'm in the same position as the original poster and could do with the sample app for the calculator if its still available (the link no longer works). Don't know where to start at the moment.

Thanks in advance.

Cheers

Jon

Here is the link...

http://www.megaupload.com/?d=M6BUW3NJ

I couldn't believe it wen i saw a new post on this. It's been like 5 months. Anyway, hope this helps. Also, if you interested in programming you have to check out iPhoneDevCentral.org . Watch my video tutorials under the name Nitrex88 in the intermediate and advanced section and you could learn a lot about cocoa and objective-C in relation to the iPhone. Hope you enjoy!

Cheers.
 

GingerSnap

macrumors newbie
Jul 29, 2008
1
0
I tried to convert the calculator app to iPhone. But it uses NSTextField which is not available on iPhone framework. I tried to use UITextField instead, but it does not have doubleValue, setDoubleValue, stringValue and setStringValue.

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