Latest 1.3.3
Homepage https://github.com/muccy/MUKContentFetch
License MIT
Platforms ios 7.0, requires ARC
Authors

CI Status
Version
License
Platform

A simple infrastracture to retrieve requested data and transform it to content object.

Usage

Say you want to get and parse a JSON resource to show its entries inside a table view. You should isolate that fetch in a dedicated class not to pollute you view controller.

@interface DucksFetch : MUKContentFetch<NSArray<Duck *> *>
@end

@implementation DucksFetch

- (void)retrieveResourceWithCompletionHandler:(void (^)(MUKContentFetchStepResultType resultType, id retrievedObject, NSError *error))completionHandler
{
    dispatch_async(myQueue, ^{
        NSData *JSONData = ...;
        completionHandler(MUKContentFetchStepResultTypeSuccess, JSONData, nil);
    });
}

- (void)transformRetrievedObject:(id)retrievedObject withCompletionHandler:(void (^)(MUKContentFetchStepResultType resultType, id transformedObject, NSError *error))completionHandler
{
    dispatch_async(myQueue, ^{
        NSArray *ducks = ParseDucks(retrievedObject);
        completionHandler(MUKContentFetchStepResultTypeSuccess, ducks, nil);
    });
}

@end

To get data is now simple and clean.

DucksFetch *fetch = [[DucksFetch alloc] init];
[fetch startWithCompletionHandler:^(MUKContentFetchResponse *response) {
    self.ducks = response.object;
    [self updateUI];
}];

Obviously this is a small and incomplete example which does not mind about cancellation and error handling, two things you have (almost) for free using MUKContentFetch.

Requirements

  • iOS 7 SDK.
  • Minimum deployment target: iOS 7.

Installation

MUKContentFetch is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "MUKContentFetch"

Author

Marco Muccinelli, [email protected]

License

MUKContentFetch is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "MUKContentFetch",
    "version": "1.3.3",
    "summary": "Retrieve data and transform it to content objects",
    "description": "A simple infrastracture to retrieve requested data and transform it to content object",
    "homepage": "https://github.com/muccy/MUKContentFetch",
    "license": "MIT",
    "authors": {
        "Marco Muccinelli": "[email protected]"
    },
    "source": {
        "git": "https://github.com/muccy/MUKContentFetch.git",
        "tag": "1.3.3"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "Classes/**/*.{h,m}"
}

Pin It on Pinterest

Share This