• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
IBOutlet does not initialize. Newbie Q.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

IBOutlet does not initialize. Newbie Q.


  • Subject: IBOutlet does not initialize. Newbie Q.
  • From: Bernd Carl <email@hidden>
  • Date: Mon, 23 Feb 2004 17:49:26 +0100

Hello,
I'm stuck with a stupid problem, my outlet won't initialize.
This is what I have:
-A Document based app.
-two classes, one MyDocument and one called StringSplit.
-Some NSText Fields
-Connected the TextFields with StringSplit but my TextFields always return null.

I know there is something I'm missing since I read about it in a book. Thing is I don't have the book anymore :-)
Thank you very much, Bernd.

In case someone can help me I'm adding my code:

//
// MyDocument.h
// fa.ala
//
// Created by Bernd on Sun Feb 15 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//


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

@interface MyDocument : NSDocument
{
StringSplit *input;

}
- (IBAction)go:(id)sender;
@end

__________
//
// MyDocument.m
// fa.ala
//
// Created by Bernd on Sun Feb 15 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//

#import "MyDocument.h"
#import "StringSplit.h"

@implementation MyDocument

- (id)init
{
self = [super init];
if (self) {
// Add your subclass-specific initialization here.
// If an error occurs here, send a [self release] message and return nil.

}
return self;
}

- (NSString *)windowNibName
{
// Override returning the nib file name of the document
// If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
return @"MyDocument";
}

- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
[super windowControllerDidLoadNib:aController];
// Add any code here that needs to be executed once the windowController has loaded the document's window.
}

- (NSData *)dataRepresentationOfType:(NSString *)aType
{
// Insert code here to write your document from the given data. You can also choose to override -fileWrapperRepresentationOfType: or -writeToFile:ofType: instead.
return nil;
}

- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
{
// Insert code here to read your document from the given data. You can also choose to override -loadFileWrapperRepresentation:ofType: or -readFromFile:ofType: instead.
return YES;
}



- (IBAction)go:(id)sender //This is just a button to start the action.
{
input = [[StringSplit alloc]init]; [input analyse];
}
@end
______________
//
// StringSplit.h
// fa.ala
//
// Created by Bernd on Fri Feb 20 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//

#import <AppKit/AppKit.h>
//#import "MyDocument.h"

@interface StringSplit : NSObject {
NSString *testString;
NSString *r1;
NSString *r2;
NSString *r3;
IBOutlet NSTextField *textIn;
IBOutlet NSTextField *textR1;
IBOutlet NSTextField *textR2;
IBOutlet NSTextField *textR3;
IBOutlet NSTextField *textOut; }
- (void)analyse;
@end
________________
//
// StringSplit.m
// fa.ala
//
// Created by Bernd on Fri Feb 20 2004.
// Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//

#import "StringSplit.h"


@implementation StringSplit

- (id)init
{
self = [super init];
if (self) {
// Add your subclass-specific initialization here.
// If an error occurs here, send a [self release] message and return nil.
}
return self;
}

- (void)analyse //This method is supposed to split the string into parts.
{ // I know it doesn't look nice but the Logs
NSRange range3, range6; //always return TextIn = null.
unsigned int index, a;
index=1;
testString = [[NSString alloc]init];
r1 = [[NSString alloc]init];
r2 = [[NSString alloc]init];
r3 = [[NSString alloc]init];

testString = @"wew";
a = [testString length];
NSLog(@"Ldnge = %i",a);
[textIn setStringValue:@"TTT"];
NSLog(@"TextIn = %@",textIn);
if (a == 3) {
NSLog(@"nur 3");
range3.length = 1;
range3.location = 0;
r1 = [testString substringWithRange:range3];
[textR1 setStringValue:r1];
range3.location = 1;
r2 = [testString substringWithRange:range3];
[textR2 setStringValue:r2];
range3.location = 2;
r3 = [testString substringWithRange:range3];
[textR3 setStringValue:r3];
}
if (a == 6) NSLog(@"alle 6");
}
@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: IBOutlet does not initialize. Newbie Q.
      • From: Amul Goswamy <email@hidden>
    • A Question about StuffIt SDK
      • From: Yury Peskin <email@hidden>
  • Prev by Date: Re: [Slightly OT] Shareware donation collection
  • Next by Date: A Question about StuffIt SDK
  • Previous by thread: [ANN] Graphviz 1.10 (v4) for Mac OS X
  • Next by thread: A Question about StuffIt SDK
  • Index(es):
    • Date
    • Thread