Retaining 2D array values
Retaining 2D array values
- Subject: Retaining 2D array values
- From: "jz" <email@hidden>
- Date: Fri, 30 Dec 2005 16:02:01 -0500 (EST)
1. How do I retain old values in a global array after a value change?
2. When do I use a nonpointer type the accessor methods vs. pointer to an object in the setters?
I'd appreciate help.
Thanks, and A Happy New Year.
Here is my little code:
=============== Controller =================
#import <Cocoa/Cocoa.h>
int gM[8][8];
@interface Controller : NSObject { }
- (IBAction)show:(id)sender;
- (int)gM;
- (void)setGM: (int)aGM;
@end
---------------------------------------
@implementation Controller
- (IBAction)show:(id)sender {
gM[1][1] = 111;
//array display code...
}
- (int )gM { return gM[8][8]; }
- (void)setGM: (int)aGM {
gM[8][8] = aGM;
//memmove(gM, &aGM, sizeof(gM[8][8])); //This is an alternative
}
@end
=============== ClassA =================
#import <Cocoa/Cocoa.h>
#import "Controller.h"
@interface ClassA : NSObject {
IBOutlet Controller *toController;
}
- (IBAction)update1:(id)sender;
@end
---------------------------------------
@implementation ClassA
- (IBAction)update1:(id)sender {
gM[1][0] = 122;
//[toController setGM: qM[1][0] = 1 ]; //An alternative
//array display code...
}
@end
_______________________________________________
Join Excite! -
http://www.excite.com
The most personalized portal on the Web!
_______________________________________________
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