seventeenfive seventeenfive - 5 months ago 16
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.


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"]];