Permalink
Browse files

Updates to show offf the new block system

  • Loading branch information...
1 parent f0ad66d commit 4b3d0841dfcc3e211273226700589dc45e9b4fb4 @kylebrowning committed Mar 26, 2012
Showing with 15 additions and 39 deletions.
  1. +11 −11 DIOSView.h
  2. +4 −28 DIOSView.m
View
@@ -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
View
@@ -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.