seventeenfive seventeenfive - 2 years ago 153
Objective-C Question

Insert Character into NSString or convert to intValue

Probably very simple but I'm banging my head trying to figure it out.

I have this string, either as

or just

-(NSMutableString *)timeSet{
return [[NSUserDefaults standardUserDefaults] valueForKey:@"timeSet"];

Which I'm then outputting using this:

arguments[curArg++]=(char *)[[self timeSet] UTF8String];

And I need to insert a hyphen to the front of the output. So if the value of timeSet is twelve it is read as -twelve.

Answer Source

Have you tried something like:

return [NSString stringWithFormat:@"-%@", 'your otput here'];

And your method will look like this:

   -(NSString *)timeSet{

        return [NSString stringWithFormat:@"-%@", [[NSUserDefaults standardUserDefaults] valueForKey:@"timeSet"]];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download