functions vs methods
functions vs methods
- Subject: functions vs methods
- From: Roland Silver <email@hidden>
- Date: Thu, 5 May 2005 07:24:06 -0600
Given one of my classes, Foo, how can I define a function (not method)
post() which accesses an instance variable textView of Foo? The
following doesn't work:
// Foo.h
#import <Cocoa/Cocoa.h>
#import <stdio.h>
@interface Foo : NSObject
{
IBOutlet NSTextView *textView;
}
... method declarations ...
void post(const char *template, ...);
@end
// Foo.m
@implementation Foo
... method definitions ...
void post(const char *template, ...) {
va_list args;
char *msg;
NSString *nsMsg;
va_start(args, template);
vasprintf(&msg, template, args);
va_end(args);
nsMsg = [NSString stringWithCString:msg];
[textView insertText:nsMsg]; //<------- error: 'textView' undeclared
} //end post
@end
_______________________________________________
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