Re: Beginners question regarding NSFileHandle
Re: Beginners question regarding NSFileHandle
- Subject: Re: Beginners question regarding NSFileHandle
- From: Finlay Dobbie <email@hidden>
- Date: Tue, 7 Aug 2001 00:15:58 +0100
On Monday, August 6, 2001, at 08:13 pm, Roger Gilliar wrote:
I have the following code, that causes a signal 10 (SIGBUS) error:
{
id fh;
fh = [NSFileHandle fileHandleForReadingAtPath:@"/private/tmp/test"];
this line is a convenience constructor and returns an autorelease'd
NSFileHandle. You then proceed to release it, meaning it has a retain
count of 0 and is deallocated. Later, the NSAutoreleasePool will
-release your object, but it has already been deallocated, so this
causes problems. See
http://www.stepwise.com/Articles/Technical/2001-03-11.01.html
BTW: Is it possible to use the NSFileHandle type for fh instead of the
generic id type ?
But of course! Make sure you declare it as NSFileHandle *fh, though,
because objects cannot be statically allocated.
-- Finlay