A very handly class I've built is
asyncDataRequest. This provides for an easy way to make and receive calls to web data feeds. All you have to do is include the class reference in your .m file, make the request and create a notification responder to receive and parse that data response.
First, we'll look at
asyncDataRequest.h:
@interface asyncDataRequest : NSObject {
NSMutableData *responseData;
id delegate;
NSString *notificationName;
}
@property(nonatomic,retain) NSMutableData *responseData;
@property(nonatomic,assign) id delegate;
@property(nonatomic,retain) NSString *notificationName;
- (void)setDelegate:(id)newDelegate;
- (void)connection:(NSURLConnection *)connection didReceiveResponse: (NSURLResponse *)response;
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
- (void)connection:(NSURLConnection *)connection didFailWithError: (NSError *)error;
- (void)connectionDidFinishLoading: (NSURLConnection *)connection;
@end
Read more »Labels: asynchronous, NSNotification, NSURL, NSURLConnection, web request