Skip to content

Commit

Permalink
Updates to show offf the new block system
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebrowning committed Mar 26, 2012
1 parent f0ad66d commit 4b3d084
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 39 deletions.
22 changes: 11 additions & 11 deletions DIOSView.h
Expand Up @@ -34,16 +34,16 @@
//
// ***** END LICENSE BLOCK *****
#import "AFHTTPRequestOperation.h"
#import "DIOSSession.h"
@protocol DIOSViewDelegate;
@protocol DIOSViewDelegate <NSObject>
- (void)viewGetDidFinish:(BOOL)status operation:(AFHTTPRequestOperation *)operation response:(id)response error:(NSError*)error;
@end

@interface DIOSView : NSObject <DIOSViewDelegate>{
id <DIOSViewDelegate> delegate;
}
@property (weak, nonatomic) id <DIOSViewDelegate> delegate;
- (id) initWithDelegate:(id<DIOSViewDelegate>)aDelegate;
- (void)viewGet:(NSDictionary *)params;
@interface DIOSView : NSObject

/**
Returns the contents of the specified Drupal view. Implementation takes two blocks, one for success, and one for failure. Either parameter may be nil.
@param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request.
@param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occured during the request.
*/
- (void)viewGet:(NSDictionary *)params success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
@end
32 changes: 4 additions & 28 deletions DIOSView.m
Expand Up @@ -34,34 +34,10 @@
//
// ***** END LICENSE BLOCK *****
#import "DIOSView.h"

#import "DIOSSession.h"
@implementation DIOSView
@synthesize delegate = _delegate;

- (id) initWithDelegate:(id<DIOSViewDelegate>)aDelegate {
self = [super init];
if (!self) {
return nil;
}
[self setDelegate:aDelegate];
return self;
}
- (void)viewGet:(NSDictionary *)params {
[[DIOSSession sharedSession] getPath:[NSString stringWithFormat:@"%@/%@/%@", kDiosEndpoint, kDiosBaseView, [params objectForKey:@"view_name"]] parameters:params success:^(__unused AFHTTPRequestOperation *operation, id JSON) {
if ([_delegate respondsToSelector:@selector(viewGetDidFinish:operation:response:error:)]) {
[_delegate viewGetDidFinish:YES operation:operation response:JSON error:nil];
} else {
DLog(@"I couldnt find the delegate and one was set %@ for this get so my response will never be used.", _delegate);
}
} failure:^(__unused AFHTTPRequestOperation *operation, NSError *error) {
if ([_delegate respondsToSelector:@selector(viewGetDidFinish:operation:response:error:)]) {
[_delegate viewGetDidFinish:NO operation:operation response:nil error:error];
} else {
DLog(@"I couldnt find the delegate and one was set %@ for this get so my response will never be used.", _delegate);
}
}];
}
- (void)viewGetDidFinish:(BOOL)status operation:(AFHTTPRequestOperation *)operation response:(id)response error:(NSError*)error {

- (void)viewGet:(NSDictionary *)params success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
[[DIOSSession sharedSession] getPath:[NSString stringWithFormat:@"%@/%@/%@", kDiosEndpoint, kDiosBaseView, [params objectForKey:@"view_name"]] parameters:nil success:success failure:failure];
}
@end

0 comments on commit 4b3d084

Please sign in to comment.