Archive

Posts Tagged ‘Xcode’

Create a socket based iPhone App and Server

Categories: Programming, Uncategorized Tags: ,

Xcode change the button title at run time

Change the button title at run time

If you’ve got a button that’s hooked up to an action in your code, you can change the title without an instance variable.

if the button is set to this action:

-(IBAction)startSomething:(id)sender;

-(IBAction)startSomething:(id)sender {

[sender setTitle:@”Hello” forState:UIControlStateNormal];

}

Or toggle the name of the button, you can create a BOOL named “buttonToggled” (for example), and toggle the name this way:

-(IBAction)toggleButton:(id)sender {

if(!buttonToggled){

[sender setTitle:@”Something” forState:UIControlStateNormal];

buttonToggled = YES;

}

else{

[sender setTitle:@”Different” forState:UIControlStateNormal];

buttonToggled = NO;

}

}

Categories: Programming Tags:

Xcode add a tag to the textField

To distinguish textFields,  add a tag (in Interface Builder) to the textField,

-(void)textFieldDidBeginEditing:(UITextField *)textField {

if (textField.tag == 2) {

//this is textfield 2, so call your method here

}

}

Categories: Programming Tags:

Xcode adding two string

Xcode adding two strings
NSString*addStr=[firstString stringByAppendingString: secondString];

Categories: Programming Tags: