• 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
Re: Beginners question regarding NSFileHandle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Beginners question regarding NSFileHandle (From: "Roger Gilliar" <email@hidden>)

  • Prev by Date: Re: Beginners question regarding NSFileHandle
  • Next by Date: Subclassing/wrapping NSTask?
  • Previous by thread: Re: Beginners question regarding NSFileHandle
  • Next by thread: NSNotification vs message callback?
  • Index(es):
    • Date
    • Thread