How to clear cookies from NSHTTPCookieStorage more then once?

+(void)clearAllCookies {
    NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    for (NSHTTPCookie *each in cookieStorage.cookies) {
        [cookieStorage deleteCookie:each];
    }
}

I know this is an old question, but here is the answer. We are currently using this with our app to clear out ALL cookies for UIWebView (this only has access to cookies in your app, not shared cross apps in any way).

If you want to clear only specific ones, you can always check the properties of each cookie object before deciding if you want to delete it or not. for example cookie.name isEqualToString@"somename"

Hopefully this helps someone out there.

Edit: as of some iOS version there is an easier way now, there is a new method to clear out cookies by date.

NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
[cookieStorage removeCookiesSinceDate:[NSDate dateWithTimeIntervalSince1970:0]];

SWIFT 4.X version: (a lot simpler, one liner)

HTTPCookieStorage.shared.cookies?.forEach(HTTPCookieStorage.shared.deleteCookie)