Re: textView outlet problem
Re: textView outlet problem
- Subject: Re: textView outlet problem
- From: simone gabbriellini <email@hidden>
- Date: Mon, 7 Mar 2005 17:38:36 +0100
Inizio del messaggio inoltrato:
Da: simone gabbriellini <email@hidden>
Data: 07 marzo 2005 16:09:01 CET
A: "Sven Hoffmann" <email@hidden>
Oggetto: Re: textView outlet problem
Hi Sven,
no problem to post all the code I wrote so far (the "save to file" part works so I put here only the "load from file" part):
In MyDocument.h I have:
/* MyDocument */
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
@interface MyDocument : NSDocument
{
IBOutlet NSTextView *contenutoInvito;
IBOutlet NSTextField *immagineInvito;
IBOutlet NSTextView *messaggioInvito;
IBOutlet NSTextField *titoloInvito;
NSMutableArray *saveData;
NSMutableArray *loadData;
NSString *messaggio;
NSString *titolo;
NSString *contenuto;
NSString *immagine;
}
-(void)encodeWithCoder:(NSCoder *)coder;
- (id)initWithCoder:(NSCoder *)coder;
- (void)setValori:(NSMutableArray *)unValore;
@end
In MyDocument.m I have:
- (BOOL)loadDataRepresentation:(NSData *)newData ofType:(NSString *)aType
{
// if the file type is correct:
if([aType isEqualToString:@"invitiEase"]){
// Init the array with capacity equls to 4:
loadData = [[NSMutableArray alloc]initWithCapacity:4];
// Unarchive the data stored in the file:
loadData = [NSUnarchiver unarchiveObjectWithData:newData];
}
return YES;
}
- (void)setValori:(NSMutableArray *)unValore
{
[unValore retain];
messaggio = [unValore objectAtIndex:0];
titolo = [unValore objectAtIndex:1];
contenuto = [unValore objectAtIndex:2];
immagine = [unValore objectAtIndex:3];
// this doesn't work
[messaggioInvito insertText:messaggio];
// this give me back (null)
printf("%s\n", [[messaggioInvito description] UTF8String]);
}
- (id)initWithCoder:(NSCoder *)coder
{
// Decoding data sending its contents to setValori method:
[self setValori:[coder decodeObject]];
return self;
}
Hope you can help me,
Simone
Il giorno 07/mar/05, alle 16:02, Sven Hoffmann ha scritto:
Hi simone,
Let me guess what you did so far:
1.You created a new project in xcode.
2.You opened the mainMenu.nib file and created added a NSTextView to the
window in Interfacebuilder.
3.You subclassed NSObject with something like myController.m and added
an outlet "messagioInvito" to the class.
4.you instantiated the class to add an object to the nibfile and made
the connection(ctrl-drag) from the controller outlet to the textView.
5.You let interface builder create the myController.m and .h files and
added code to the xcode main function to put your string mssagio into
the textView: [messaggioInvito insertText:messaggio];
If that is what you did it should work. If not, try it like that.
The information you gave about what you did is, let's say, incomplete,
so maybe post a bit more of the source and we will be able to help you.
Sven
------------------------------------------------------------------------
------------
Sven Hoffmann
R&D Macintosh Software Develover
Email: email@hidden Tel. 03-6362211
Aladdin Knowledge Systems Ltd.
http://www.aladdin.com <http://www.aladdin.com/>
________________________________
From: cocoa-dev-bounces+sven.hoffmann=email@hidden
[mailto:cocoa-dev-bounces+sven.hoffmann=email@hidden] On
Behalf Of simone gabbriellini
Sent: 07 March, 2005 16:34
To: Cocoa Mailing List
Subject: textView outlet problem
Dear List,
I have a textView outlet (messaggioInvito) in which I would load a
NSString (messaggio)
My code is:
[messaggioInvito insertText:messaggio];
but it seems that the outlet doesn't listen, and in the GUI nothing
happens.
If I ask to printf the variable after this assignment, I have:
(null)
as an answer.
The textView is editable by the user, and messaggio do have a string
stored.
cannot understand why this happens.
any help welcome
thank you,
simone
**************************************************************************************************
The contents of this email and any attachments are confidential.
It is intended for the named recipient(s) only.
If you have received this email in error please notify the system manager or the
sender immediately and do not disclose the contents to anyone or make copies.
** eSafe scanned this email for viruses, vandals and malicious content **
**************************************************************************************************
_______________________________________________
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