-[NSHTTPCookieStorage cookies] updates in Tool but not in App
-[NSHTTPCookieStorage cookies] updates in Tool but not in App
- Subject: -[NSHTTPCookieStorage cookies] updates in Tool but not in App
- From: Jerry Krinock <email@hidden>
- Date: Tue, 27 Mar 2007 18:40:54 -0700
As a troubleshooting/understanding experiment, I've set a timer to
send -[NSHTTPCookieStorage cookies] every 3 seconds, to see if the
returned array shows the cookie additions or deletions executed in
Safari.
The result is that, if I do this in a Foundation Tool, the returned
array of cookies changes as expected after a few seconds, but if I
use the exact same code in a Cocoa Application, the returned array
never changes.
Does it have something to do with the run loop?
Thanks,
Jerry Krinock
Note: I tried deleting cookies both by visiting a "logout" web page
(to delete session cookies) and by deleting cookies in Safari's
Preferences. Same result in either case.
*** CookieChecker class used in both projects ***
@interface CookieChecker : NSObject
@end
@implementation CookieChecker
- (void)check:(NSTimer*)timer {
NSHTTPCookieStorage* sharedCookieStorage =
[NSHTTPCookieStorage sharedHTTPCookieStorage] ;
NSArray* cookies = [sharedCookieStorage cookies] ;
NSLog(@"You have %5i cookies.", [cookies count]) ;
}
@end
*** Foundation Tool ***
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
CookieChecker* checker = [[CookieChecker alloc] init] ;
[NSTimer scheduledTimerWithTimeInterval:3.0
target:checker
selector:@selector(check:)
userInfo:nil
repeats:YES] ;
[[NSRunLoop currentRunLoop] run] ;
[pool release];
return 0;
}
*** Cocoa Application ***
@implementation AppController
- (void)applicationDidFinishLaunching:(NSNotification *)note {
// Same code! :
CookieChecker* checker = [[CookieChecker alloc] init] ;
[NSTimer scheduledTimerWithTimeInterval:3.0
target:checker
selector:@selector(check:)
userInfo:nil
repeats:YES] ;
}
@end
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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