Re: Newby Question
Re: Newby Question
- Subject: Re: Newby Question
- From: Daniel DeCovnick <email@hidden>
- Date: Sat, 9 Jul 2005 22:02:31 -0700
Rick,
This is what you need:
#import <Cocoa/Cocoa.h>
//or, alternately, just Foundation/Foundation.h, unless this uses appkit
const int ARRAY_CAPACITY = 10;
@interface MyArrayClass : NSObject
{
int anArray[ARRAY_CAPACITY];
}
- (int *)anArray;
- (void)setAnArray:(int *)bArray;
@end
------------------------------------------
#import "MyArrayClass.h"
@implementation MyArrayClass
- (int *)anArray { return anArray; } //without the *, you'd only
return the first element in the array
- (void)setAnArray:(int *)bArray //no return; typecast to void. Also
need a pointer to pass
{
int i;
for (i = 0; i < ARRAY_CAPACITY; i++)
{
anArray[i] = bArray[i];
} //the above ensures no buffer overflows.
}
@end
-Dan
Daniel DeCovnick
danhd123 at mac dot com
Softyards Software
http://www.softyards.com
On Jul 9, 2005, at 5:45 PM, R T wrote:
I'm using an array in a class and I'm not sure how to
write the get and set methods...can anyone correct
these lines.
#import <Cocoa/Cocoa.h>
@interface MyArrayClass : NSObject
{
int anArray[10];
}
- (void)anArray;
- (int)setAnArray:(int)bArray;
@end
___________________________________
#import "MyArrayClass.h"
@implementation MyArrayClass
- (int)anArray { return anArray; }
- (int)setAnArray:(int)bArray { anArray = bArray; }
@end
Thanks
Rick T.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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
_______________________________________________
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