• 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
[ANN] AMURLLoader
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ANN] AMURLLoader


  • Subject: [ANN] AMURLLoader
  • From: Andreas Mayer <email@hidden>
  • Date: Mon, 13 Sep 2004 03:26:02 +0200

Now that I have figured out NSURLRequest/NSURLConnection, I decided that I needed a simpler interface to it. This is what I came up with:

+ (AMURLLoader *)loaderWithURL:(NSURL *)url target:(id)target selector:(SEL)selector userInfo:(id)theUserInfo;


And this is how you use it:

[AMURLLoader loaderWithURL:url target:self selector:@selector(didReceiveData:context:) userInfo:nil];


- (void)didReceiveData:(NSData *)data context:(NSDictionary *)context
{
if (data) {
int statusCode = 0;
NSURLResponse *response = [context objectForKey:@"response"];
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
statusCode = [(NSHTTPURLResponse *)response statusCode];
NSLog(@"status: %i", statusCode);
}
if (statusCode < 400) {
// do something with data
}
} else {
NSLog(@"error: %@", [(NSError *)[context objectForKey:@"error"] localizedDescription]);
}
}



Full code here:

<http://www.harmless.de/cocoa.html#urlloader>

Have fun!


Andreas

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: persistentObjectForItem in NSOutlineView
  • Next by Date: Re: New ML List Software
  • Previous by thread: persistentObjectForItem in NSOutlineView
  • Next by thread: Multiple Copies of a window
  • Index(es):
    • Date
    • Thread