ios - UISegmentedControl and NSString

Posted by Jeff Kranenburg on Stack Overflow See other posts from Stack Overflow or by Jeff Kranenburg
Published on 2012-06-23T20:57:28Z Indexed on 2012/06/23 21:16 UTC
Read the original article Hit count: 219

Filed under:
|
|

Hello I have the following code:

if(_deviceSegmentCntrl.selectedSegmentIndex == 0)
{
    deviceOne = [[NSString alloc] initWithFormat:@"string01"];
}
if(_deviceSegmentCntrl.selectedSegmentIndex == 1)
{
    deviceOne = [[NSString alloc] initWithFormat:@"string02"];
}
if(_deviceSegmentCntrl.selectedSegmentIndex == 2)
{
    deviceOne = [[NSString alloc] initWithFormat:@"string03"];
}

NSString *deviceType = [[NSString alloc] initWithFormat:_deviceSegmentCntrl];

I am wanting to have the NSString output the string the user selects in the segmented control.

How do I append the initWithFormat: so that it reflects the chosen index?

Cheers

© Stack Overflow or respective owner

Related posts about ios

Related posts about nsstring