views:

117

answers:

2

Ok, I got used to coding with PHP. I'm currently trying to do a sudoku app. Now I'm coming to a point where I need to show the proper number in the appropriate cell (UITextfield) based on the number pressed. (I have 9 buttons that correspond to 1-9 respectively)

Conceptually when the used clicks on a cell, I want to: 1. put the UITextField name and put it in a string so that 2. when a user clicks on the number I tell the computer "Ok, put this number in (refer to our string variable) this cell"

I'm basically more concerned of paragraph 2. I've come upon this problem several times. In php, all we need is put a $ sign, concatenate strings then it'll be considered a variable. I'm wondering what the similar process for it in iphone sdk.

Please and thank you folks

A: 

Just set a pointer.

tc.
how do i do that? can you give me an example?
Dan
A: 

Objective-C is less like PHP and more like all the languages where you have to declare your variable at some point:

int myNumber = 9;
NSString *fieldText = @"Number:";
NSString *appendedText = [fieldText stringByAppendingFormat: @"%@ %d", myNumber];

It's also much more wordy :-)

jbm