• 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: [NSFileHandle isOpen]?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NSFileHandle isOpen]?


  • Subject: Re: [NSFileHandle isOpen]?
  • From: claw <email@hidden>
  • Date: Sun, 13 Feb 2011 08:37:22 +0100

>>> Is there a way to determine if a NSFileHandle object has been sent a closeFile message?
>

and what about implement your own method like:
-(void)sendActionToFile: actualState:(NSDictionary *)userInfo;

'userInfo' is a dictionary filled with state information just before using NSFileHandle
in order to test if there is still events in waiting associated with this file
of course ,you can determine in advance that you already sent twice closeFile , if nothing happened there is a problem.... so first  you can send the message with cocoa, second why not asking the kernel why the file refuse to be closed (already a user reading & writting on it ? policy associated with the file ? and so on !).






Le 12 févr. 2011 à 19:00, A.M. a écrit :

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

 _______________________________________________
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

References: 
 >[NSFileHandle isOpen]? (From: Programmingkid <email@hidden>)
 >Re: [NSFileHandle isOpen]? (From: Quincey Morris <email@hidden>)
 >Re: [NSFileHandle isOpen]? (From: Programmingkid <email@hidden>)
 >Re: [NSFileHandle isOpen]? (From: "A.M." <email@hidden>)

  • Prev by Date: Re: Debugging and alert panels
  • Next by Date: Re: Mix and match project build configurations
  • Previous by thread: Re: [NSFileHandle isOpen]?
  • Next by thread: Re: [NSFileHandle isOpen]?
  • Index(es):
    • Date
    • Thread