• 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: Why are properties access through NSURLProtocol class method rather than NSURLRequest instance method?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why are properties access through NSURLProtocol class method rather than NSURLRequest instance method?


  • Subject: Re: Why are properties access through NSURLProtocol class method rather than NSURLRequest instance method?
  • From: Mike Abdullah <email@hidden>
  • Date: Mon, 16 May 2011 10:45:30 +0100

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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >Why are properties access through NSURLProtocol class method rather than NSURLRequest instance method? (From: Larry Campbell <email@hidden>)

  • Prev by Date: Re: Delegate & Notification
  • Next by Date: Re: NSPostWhenIdle not doing its job?
  • Previous by thread: Why are properties access through NSURLProtocol class method rather than NSURLRequest instance method?
  • Next by thread: How to use the NSCache
  • Index(es):
    • Date
    • Thread