• 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: -[NSHTTPCookieStorage cookies] updates in Tool but not in App
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -[NSHTTPCookieStorage cookies] updates in Tool but not in App


  • Subject: Re: -[NSHTTPCookieStorage cookies] updates in Tool but not in App
  • From: Jerry Krinock <email@hidden>
  • Date: Fri, 30 Mar 2007 16:28:34 -0700

I've also now tried to run the CookieChecker in a separate thread of my App, but still the same results: It does not update when cookies are changed in Safari.

To resolve the issue, I've now worked around it by using a kludge from other information instead. If no one posts an explanation, I'll submit a bug report.

Jerry Krinock

*** Cocoa Application, Threaded Version ***

@implementation AppController

- (void)checkThreaded:(id)nilly {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init] ;

    // Same code:
    CookieChecker* checker = [[CookieChecker alloc] init] ;
    [NSTimer scheduledTimerWithTimeInterval:3.0
                                     target:checker
                                   selector:@selector(check:)
                                   userInfo:nil
                                    repeats:YES] ;
    [[NSRunLoop currentRunLoop] run] ;

    [pool release] ;
}	

- (void)applicationDidFinishLaunching:(NSNotification *)note {
	[NSThread detachNewThreadSelector:@selector(checkThreaded:)
                                 toTarget:self
                               withObject:nil] ;
}	

@end

On 2007 Mar, 27, at 18:40, Jerry Krinock wrote:

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

_______________________________________________

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


References: 
 >-[NSHTTPCookieStorage cookies] updates in Tool but not in App (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Core Data Memory issue on loading a saved file
  • Next by Date: Re: Core Data Memory issue on loading a saved file - Solved
  • Previous by thread: -[NSHTTPCookieStorage cookies] updates in Tool but not in App
  • Next by thread: [Q] NSTextView Binding property
  • Index(es):
    • Date
    • Thread