discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Localization with NSString


From: David Chisnall
Subject: Re: Localization with NSString
Date: Tue, 22 Jun 2010 15:07:39 +0100

On 22 Jun 2010, at 14:59, Paul Chany wrote:

> main.m:39: warning: passing argument 1 of ‘printf’ from incompatible
> pointer type 


Without looking at your code[1], the error seems to be that you are passing an 
Objective-C string to a function that expects a C string, in this case to the C 
standard library function printf().

You have two options.  You can either pass the string to something that expects 
an object, like NSLog(), like this:

Log(@"My string: %@", mystring);

This will log the Objective-C string and some metadata about the process.  
Alternatively, you can get a C-string representation of the Objective-C string 
object by sending it a -UTF8String message, like this:

printf("%s\n", [mystring UTF8String]);

(If you need the string in another encoding, see the NSString documentation)

David

[1] If you want people to help you, it's generally a good idea to make it easy 
for them to help.  This means putting relevant snippets of the code in your 
email, not expecting people to grab a file via FTP and unzip it.

-- Sent from my IBM 1620




reply via email to

[Prev in Thread] Current Thread [Next in Thread]