object ownership question
object ownership question
- Subject: object ownership question
- From: Candide Kemmler <email@hidden>
- Date: Mon, 2 Jul 2001 11:53:45 +0200
Hi !
I'm just not used to be concerned about object ownership. Until
yesterday I didn't even know what a pointer was...
Now, my application crashes for a problem I think is related to object
ownership:
I have a button that gets data from a URL:
id url = [[NSURL alloc]
initWithString:@"
http://localhost:8080/mapping/servlet/service"];
id handle = [ url URLHandleUsingCache:false ];
NSData *data = [ handle resourceData ];
[ mapView set
Data:data ];
in MapView, here's the setData method:
- ( void ) setData: ( NSData * ) data
{
// char *buffer;
// char **bufferHandle;
myData = data;
// buffer = ( char * ) [ myData bytes ];
// bufferHandle = &buffer;
// buffer += 4;
// NSLog ( @"\nthe float value is %f", readFloat ( bufferHandle ) );
}
the myData instance variable in MapView is defined like so:
@interface MapView : NSView
{
NSData *myData;
}
- (void)drawRect:(NSRect)frame;
- ( void ) setData: ( NSData * ) data;
@end
The commented code in setData works, which means that the myData object
contains valid data.
However, when I try to execute the same code in drawRect, my application
crashes.
Who could shed some light for me on this basic topic ?
Thanks in advance,
Candide