Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

BollywooD

macrumors 6502
Original poster
Apr 27, 2005
372
46
Hamburg
I found this code, online - and it seems like it would do what I want. that is clear the NSHTTPCookieStorage immediately. However it wont compile?

It gives me the error:
Code:
error Ivar undeclared, error ivar undeclared

heres the code:

Code:
Ivar    ivar;
void*   internal = NULL;
ivar = object_getInstanceVariable(storage, "_internal", &internal);
if (internal) {
	void*   diskStorage = NULL;
	ivar = object_getInstanceVariable((id)internal, "storage", &diskStorage);
	if (diskStorage) {
		objc_msgSend(diskStorage, @selector(_saveCookies));
		}
	}

Im still learning cocoa, and I cant get my head around this, does anyone know what going wrong here?

I am compiling for Leopard
thanks in advance
 
To fix the compile error add #import <objc/objc-class.h>

That code may work for 10.4, but not for 10.5. What it's doing is equivalent to
[storage->_internal _saveCookies] but _saveCookies is no longer defined as a method on the _internal object (which really is NSHTTPCookieStorageInternal), and so it will no longer work on Leopard.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.