Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

zippyfly

macrumors regular
Original poster
Mar 22, 2008
141
0
How come I get an error about "makes pointer from integer without a cast" from this code:

Code:
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
	
	NSString *myString = @"Results: ";
	
	NSLog(@"%@",myString);

	myString = [myString stringByAppendingString:@"The winner is number "];
	
	NSLog(@"%@",myString);
	
	int i = 1;

[B]	myString = [myString stringByAppendingFormat:("%i",i)];[/B]

	NSLog(@"%@",myString);
	
    [pool drain];
    return 0;
	
}

I tried writing

Code:
myString = [myString stringByAppendingFormat:("%i", [B](int)[/B] i)];
but it didn't work either.
 
I tried that before and it said (and still says):

Format not a string literal and no format arguments.
 
Drop the parenthesis

Code:
myString = [myString stringByAppendingFormat:@"%i", i];
 
Much thanks. Works now:

Code:
myString = [myString stringByAppendingFormat:@"%i",i];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.