Int to String?

Dogcow

Registered
I have a 2-d Integer array and an NSString. How can I append an integer onto the back of NSString? I normally use appendString for strings, but does anyone know how to put the int into it?

Thanks,
-Dogcow "moof!"
 
Code:
[NSString stringWithFormat:@"%@ %i",oldStr,integer]

Or you could do

Code:
[NSString appendStringWithFormat:@"%i",integer]
 
Code:
#import "test.h"

@implementation test

- (IBAction)testAction:(id)sender
{
    int myInt = 30;
    testString = [[NSMutableString alloc] init];
    //testString = @"This is a \n test of strings";
    [testString appendString:@"This is a \n test of strings"];
    [testString appendString:@"\n more text"];
    
    [NSMutableString appendStringWithFormat:@"%i",myInt];
    
    [textField setString:testString];
    [testString release];
}

@end

/usr/bin/gcc3 -c -F/Users/dfalling/Documents/Code/Freelance/practice/textFields/build -I/Users/dfalling/Documents/Code/Freelance/practice/textFields/build/include -arch ppc -fno-common -fpascal-strings -O0 -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -pipe "-fmessage-length=0" -mdynamic-no-pic -g -Wp,-header-mapfile,/Users/dfalling/Documents/Code/Freelance/practice/textFields/build/textFields.build/textFields.build/textFields.hmap --load-pch /Users/dfalling/Documents/Code/Freelance/practice/textFields/build/textFields.build/textFields.build/PrefixHeaders/textFields_Prefix-ppc.pfe test.m -o /Users/dfalling/Documents/Code/Freelance/practice/textFields/build/textFields.build/textFields.build/Objects-normal/ppc/test.o
test.m: In function `-[test testAction:]':
test.m:13: warning: cannot find class (factory) method
test.m:13: warning: return type for `appendStringWithFormat:' defaults to id
test.m:13: warning: cannot find class (factory) method
test.m:13: warning: return type for `appendStringWithFormat:' defaults to id

What's wrong with this?

Thanks,
-Dogcow "moof!"
 
Hm... Compiles fine, but the integer doesn't show up at all...

Code:
#import "test.h"

@implementation test

- (IBAction)testAction:(id)sender
{
    int myInt = 30;
    testString = [[NSMutableString alloc] init];
    //testString = @"This is a \n test of strings";
    [testString appendString:@"This is a \n test of strings"];
    [testString appendString:@"\n more text"];
    
    [testString stringByAppendingFormat:@"%i",myInt];
    
    [textField setString:testString];
    [testString release];
}

@end

Ideas?

Thanks,
-Dogcow "moof!"
 
Back
Top