Re: [NSFileHandle isOpen]?
Re: [NSFileHandle isOpen]?
- Subject: Re: [NSFileHandle isOpen]?
- From: "A.M." <email@hidden>
- Date: Sat, 12 Feb 2011 13:00:57 -0500
On Feb 12, 2011, at 11:17 AM, Programmingkid wrote:
>
> On Feb 12, 2011, at 4:12 AM, Quincey Morris wrote:
>
>> On Feb 11, 2011, at 22:23, Programmingkid wrote:
>>
>>> Is there a way to determine if a NSFileHandle object has been sent a closeFile message?
>>
>> This is probably the wrong list -- it's more of a Cocoa question than an Xcode question.
>>
>> It looks like there's no direct way to find out. I can think of two indirect ways which might work depending on what you're trying to do:
>>
>> 1. Subclass NSFileHandle and override 'closeFile'. That way you know for sure.
>>
>> 2. Something hacky like this:
>>
>> BOOL isClosed = NO;
>> @try {
>> [fileHandle fileDescription];
>> }
>> @catch (NSException*) exception {
>> isClosed = YES;
>> }
>>
>>
>
> I actually have thought about doing it that way. I am sure there is a better way.
Under normal circumstances (closeOnDealloc:YES), you shouldn't need to close the file handle manually. In general, it is impossible to determine if a file descriptor has been closed because file descriptors are reused, so you need to do your own resource tracking.
Perhaps you can be more specific as to why detecting the close is important and we can provide further guidance.
Cheers,
M _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden