Hi all, this is my first post to the list so I'll present myself.

My name is Francis Perea and I've been a programmer for a long time (C, Pascal, PHP, Visual Basic) but I'm totally new to Mac Development and I'm doing my bests to finish my first little Mac OS X application with Objective-C and Cocoa.

By the momment all goes nice except a little trouble that is driving me crazy.

The main window of the application shows sometimes, that is the window appears but instantly it disappears.

One each of every four or five times I run the application, the window remains open and the application runs perfectly, but that's only when the window wants to remain.

When the main window disappears the application remain open and I can even call the about window but I can't recover the main one.

The code has two classes one for the model (generator) and another for the controller (generatorcontroller).

I've made lots of changes trying to discover why, but no results. I suppose I has to be something with the init method of the model, but I'm unable to determine it.

Garbage Collection is on in Xcode.

Any light in my way, plis?

Here it is the code in case anyone can help me.

Thanks in advance,

Francis Perea

____________

#import <Cocoa/Cocoa.h>


@interface Generator : NSObject {
NSString *cadena;
NSMutableArray *valores;
}
@property(copy) NSString *cadena;
@property(copy) NSMutableArray *valores;
-(void)Enciende:(int) x:(int) y:(int) state;
@end

--------------------------------------
#import "Generator.h"
#import "globales.h"

@implementation Generator
@synthesize cadena;
@synthesize valores;

- (id)init{
  int i;
  self=[super init];
  valores=[[NSMutableArray arrayWithCapacity:COLS] retain];
for(i=0; i<COLS; i++) [valores insertObject:[NSNumber numberWithInt: 0] atIndex:i];
  return self;
}

- (void)Enciende:(int) x:(int) y: (int) state{
if (state) {[valores replaceObjectAtIndex:x withObject:[NSNumber numberWithInt:BitOr([[valores objectAtIndex:x] intValue],(64>>y))]];} else {[valores replaceObjectAtIndex:x withObject:[NSNumber numberWithInt:BitAnd([[valores objectAtIndex:x] intValue],BitNot(64>>y))]];} cadena=[NSString stringWithFormat:@"{0x%x,0x%x,0x%x,0x%x,0x%x}", [[valores objectAtIndex:0] intValue],[[valores objectAtIndex:1] intValue],[[valores objectAtIndex:2] intValue],[[valores objectAtIndex: 3] intValue],[[valores objectAtIndex:4] intValue]];
}
@end

------------------------

#import <Cocoa/Cocoa.h>
#import "Generator.h"

@interface GeneratorController : NSObject {
IBOutlet NSMatrix  *botones;
IBOutlet id Col1, Col2, Col3, Col4, Col5, CopiaC, BorraTodo;
Generator *generator;
}
- (void)awakeFromNib;
- (IBAction)Maneja:(id)sender;
- (IBAction)Copia:(id)sender;
- (IBAction)Borra:(id)sender;
- (void)Refresca;
@end
-----------------------------

#import "GeneratorController.h"

@implementation GeneratorController
- (id)init
{
 self=[super init];
 generator=[[[Generator alloc]init] retain];
 return self;
}

- (void)awakeFromNib
{
 [self Refresca];
}

- (void)Refresca
{
[Col1 setStringValue: [NSString stringWithFormat:@"%0.2X", [[generator.valores objectAtIndex:0] intValue]]];
 [Col1 display];
[Col2 setStringValue: [NSString stringWithFormat:@"%0.2X", [[generator.valores objectAtIndex:1] intValue]]];
 [Col2 display];
[Col3 setStringValue: [NSString stringWithFormat:@"%0.2X", [[generator.valores objectAtIndex:2] intValue]]];
 [Col3 display];
[Col4 setStringValue: [NSString stringWithFormat:@"%0.2X", [[generator.valores objectAtIndex:3] intValue]]];
 [Col4 display];
[Col5 setStringValue: [NSString stringWithFormat:@"%0.2X", [[generator.valores objectAtIndex:4] intValue]]];
 [Col5 display];
}

- (IBAction)Maneja:(id)sender
{
  int col, row;
  [sender getRow :&row column:&col ofCell:[sender selectedCell]];
  [generator Enciende:col :row :[[sender selectedCell] state]];
  [self Refresca];
}

- (IBAction)Copia:(id)sender
{
 NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
[pasteboard declareTypes: [NSArray arrayWithObject: NSStringPboardType] owner: NULL];
 [pasteboard setString:generator.cadena forType: NSStringPboardType];
}

- (IBAction)Borra:(id)sender
{
 int col,row;
 for (row=0; row<7; row++)
  for (col=0; col<5; col++){
   [generator Enciende:col :row :NSOffState];
   [botones setState:NSOffState atRow:row column:col];
  }
  [self Refresca];
}
@end


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to