• 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
object ownership question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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 setData: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


  • Follow-Ups:
    • Re: object ownership question
      • From: Peter Ammon <email@hidden>
  • Prev by Date: Re: Working with serial ports
  • Next by Date: Re: NSEditText will not be enabled
  • Previous by thread: Re: Getting the user's name from cocoa
  • Next by thread: Re: object ownership question
  • Index(es):
    • Date
    • Thread