• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Easy one.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Easy one.


  • Subject: Re: Easy one.
  • From: Michael McCracken <email@hidden>
  • Date: Fri, 15 Jul 2005 01:23:42 -0700

%s in the format string means you want it to print a string. What
you're seeing is the result of trying to interpret a pointer to an
object as a string.
An NSString is an object, so you want to use the format specifier %@.
%@ means print the result of sending the message -description to the object.
It will usually print something useful for objects, including most
Cocoa framework objects.

HTH,
-mike

On 7/15/05, Derrick Carlin <email@hidden> wrote:
> For you. not me... heh heh
>
> I'm just learning...
>
> What is wrong with this code?...
>
> This is what it returns:
> [Session started at 2005-07-15 01:10:53 -0700.]
> 2005-07-15 01:10:53.958 dcRegCodeGenerator[3854] hello
> 2005-07-15 01:10:53.965 dcRegCodeGenerator[3854] Here is the result ¢áÀÃ
> 2005-07-15 01:10:53.965 dcRegCodeGenerator[3854] hello
>
> dcRegCodeGenerator has exited with status 0.
>
>
>
>
>
> #import <Foundation/Foundation.h>
> #import <stdio.h>
>
> @interface CodeMachine: NSObject
> {
> NSString *crypted;
>
> }
>
> -(void) setter:(NSString *) hello;
>
> @end
>
>
> @implementation CodeMachine;
>
> -(void) setter:(NSString *) hello
> {
>
> NSLog (@"hello\n");
> NSLog (@"Here is the result %s",hello);
> NSLog (@"hello\n");
> }
> @end
>
>
>
> int main(int argc, char *argv[])
> {
> CodeMachine *myCodeMachine = [[CodeMachine alloc] init];
> [myCodeMachine setter:(NSString *)@"mom"];
>
>      return 0;
> }
>
>
> Thanks for the help.
>
> -
> Derrick Carlin
>
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>


--
Michael McCracken
UCSD CSE PhD Candidate
research: http://www.cse.ucsd.edu/~mmccrack/
misc: http://michael-mccracken.net/blog/
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Easy one. (From: Derrick Carlin <email@hidden>)

  • Prev by Date: Re: Easy one.
  • Next by Date: Re: Easy one.
  • Previous by thread: Re: Easy one.
  • Next by thread: Re: Easy one.
  • Index(es):
    • Date
    • Thread