Re: removeItemAtPath in 10.7
Re: removeItemAtPath in 10.7
- Subject: Re: removeItemAtPath in 10.7
- From: sqwarqDev <email@hidden>
- Date: Thu, 27 Aug 2015 22:48:36 +0700
> On 27 Aug 2015, at 04:44, Stephane Sudre <email@hidden> wrote:
>
> Side note, you probably want to change your loop to:
>
> for(NSString * thisPath in offenderList)
> {
> }
>
I normally do use fast enum’; can’t recall why I didn’t do here, but this:
>
> offenderList.count would then be a NSUInteger and not a int
>
is a gem. Thank you. That would never have occurred to me. And neither would this:
> by defining the NSError outside
> of the loop, if one remove fails, then you will believe all the next
> removes are failing even if they succeed.
> On 26 Aug 2015, at 23:45, Conrad Shultz <email@hidden> wrote:
>
>
>> On Aug 26, 2015, at 8:11 AM, sqwarqDev <email@hidden> wrote:
>> In Cocoa, the value of the error out parameter is not guaranteed in the success case. You should test the return value of -removeItemAtPath:error: (or, better yet, -removeItemAtURL:error:) and, only if the value is NO, then inspect the error.
Lovely. These kind of tips are worth more than the solving of the actual problem. Great info, thanks.
By implementing both your and Stephane’s advice I also lost the error. I believe the error was in fact caused by the fact that I was passing an NSURL into my array and somehow squeezing an NSString out of it without either Xcode, Yosemite or Mavericks (or, of course, myself…) noticing. Hurrah for Lion, then, for putting a stop to my careless shenanigans (whoever thought I’d be cheering on 10.7! Now there’s a first.).
In any case, many thanks again to both of you.
Best
Phil
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden