futurice/mvvm-example-objc

Name: mvvm-example-objc

Owner: Futurice

Description: Example MVVM structure for iOS apps, written in Objective-C

Created: 2016-04-28 16:42:21.0

Updated: 2018-04-18 12:45:31.0

Pushed: 2016-05-06 14:29:51.0

Homepage: null

Size: 663

Language: Objective-C

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Instructions
Takeaway points
Additional material

To fetch data from a JSON backend, you can do something like this in the store:

L *url = [NSURL URLWithString:@"https://api.myjson.com/bins/nghk"];

rn [[[NSURLSession sharedSession] rac_GET:url]
map:^(RACTuple *result) {
    NSData *data = result.first;
    NSArray *peopleArray = [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL];

    NSMutableArray *people = [NSMutableArray array];
    for (NSDictionary *personDict in peopleArray) {
        Person *person = [[Person alloc] initWithFirstName:personDict[@"firstName"] lastName:personDict[@"lastName"]];
        [people addObject:person];
    }

    return [people copy];
}];

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.