Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

A couple questions from my feeble mind about Objective-C

  1. May 22, 2012 #1
    Okay. A few questions.

    Is there an escape character similar to '%s' which uses an NSString instead of a C-style string, so I could do something like NSLog(@"Hello, %N!",/*Insert NSString* here*/)?

    I tried the following code:

    Code (Text):
    #import <Foundation/Foundation.h>

    @interface Greeter : NSObject
        char name[256];
    -(void)setname : (char[256])newname;

    @implementation Greeter
    -(void)setname : (char[256])newname
        for (int i = 0;i<256;i++)
        printf("Hello, %s!",name);
        return name;
    It's not happy with my return name; expression. My mistake's probably really obvious, but what is it? Maybe I should have it return char* instead?
    Last edited: May 22, 2012
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted