- #1
Whovian
- 652
- 3
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:
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?
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:
#import <Foundation/Foundation.h>
@interface Greeter : NSObject
{
char name[256];
}
-(void)setname : (char[256])newname;
-(void)greet;
-(char[256])getname;
@end
@implementation Greeter
-(void)setname : (char[256])newname
{
for (int i = 0;i<256;i++)
{
name[i]=newname[i];
}
}
-(void)greet
{
printf("Hello, %s!",name);
}
-(char[256])getname
{
return name;
}
@end
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: