On 16 May 2011, at 03:57, Larry Campbell wrote:

> Seems odd to me that setting and getting properties of an NSURLRequest 
> involve an NSURLProtocol class method:
> 
>    +[NSURLProtocol setProperty:forKey:inRequest:]
> 
> rather than what seems to me the much more straightforward:
> 
>    -[NSMutableURLRequest setProperty:forKey:]
> 
> Is there a reason for this?

This facility is provided for people creating custom URL protocols. I think 
it's assumed that if you need custom request properties, you'll write something 
like:

@implementation NSURLRequest (MyProtocol)
- (NSString *)myFoo;
{
  return [NSURLProtocol propertyForKey:@"myFoo" inRequest:self];
}
@end

@implementation NSMutableURLRequest (MyProtocol)
- (void)setMyFoo:(NSString *)foo
{
  if (foo)
  {
    [NSURLProtocol setProperty:foo forKey:@"myFoo" inRequest:self];
  }
  else
  {
    [NSURLProtocol removePropertyForKey:@"myFoo" inRequest:self];
  }
}

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to