Does anyone honestly use RestKit?

Discussion in 'iOS Programming' started by ArtOfWarfare, May 10, 2014.

  1. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #1
    RestKit is so poorly documented that I'm finding it's a massive pain to figure out how to make it work.

    I didn't know jack about how to make a server, but using the documentation for Django Rest Framework, I was able to find out how to make a RESTful API for my server in a matter of a few hours:

    http://www.django-rest-framework.org/#tutorial

    I thought that would be the hard part, being the part I knew nothing about beforehand. Next up is making the client app for iOS. That's supposed to be the easy part, because I've been making iOS apps for years. I haven't had to dead with REST much, but I've heard plenty of people mention RestKit before, so I decided to add that to my project.

    What next?

    No, really, this is their idea of documentation:
    http://restkit.org/api/0.10.0/index.html

    Thanks, I could have read the header files myself.

    They have absolutely nothing telling you where to begin. It's just an alphabetized list of all the included classes. If this were a simple framework with 3 classes, that might cut it. It's not. It's a list of 100 classes, protocols, and categories all lumped together without any diagrams or organization to show you how to begin. No overview telling you how to make a minimal project using it. Not a single freaking thing.

    Google searches turn up a single useful result for how to use RestKit. RayWenderlich has a tutorial which purports to demonstrate RestKit, but it seems to me that the vast majority of what it contains is how to set up a basic Master - Detail iOS app.

    http://www.raywenderlich.com/58682/introduction-restkit-tutorial

    It covers how to make a GET request. And that's all.

    Flying blind from that I managed to get DELETE requests working.

    But I can't for the life of me get it to POST or PUT anything.

    Here's an example of what I've tried:

    Code:
    [manager postObject:message
                           path:@"/rantt/rantt/.json"
                     parameters:nil
                        success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
                            [mappingResult.array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
                                [self insertNewObject:(RanttMessage *)obj];
                            }];
                        } failure:nil];
    message is a simple data class with a title and a body property, each NSStrings. Running these methods, I get an error response with the suggestion:

    Code:
    NSLocalizedRecoverySuggestion={"body": ["This field is required."]
    I've checked - the body and title property each contain text. I've been trying to read the crap that RestKit outputs, but it seems to me that it's not transmitting any actual content from the message I'm giving it.
     
  2. DeltaMac macrumors 604

    DeltaMac

    Joined:
    Jul 30, 2003
    Location:
    Delaware
    #2
    Have you looked through the restkit tutorial?
    https://github.com/RestKit/RKGist/blob/master/TUTORIAL.md

    Looks like they make the grand assumption that the user will be well versed in both Cocoa and Obj-C, hence not a lot of true beginner stuff. But, looks like there's a few examples that may (or may not) prove to be helpful...

    (don't yell at me - I am ignorant about programming and systems dev. I just search around for something that looks relevant. If you are beyond that already, then I apologize - you'll need to wait for something more useful :D )
     
  3. ArtOfWarfare thread starter macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #3
    I'm getting 503: Service unavailable when I click on the link.

    It sounds like it could possibly be more useful than everything else I've found so far, though. It's an interestingly lousy choice for where to put a tutorial though - why the heck wouldn't you put it on the website that you made/setup for the framework?
     
  4. DeltaMac macrumors 604

    DeltaMac

    Joined:
    Jul 30, 2003
    Location:
    Delaware
    #4
    I assume you haven't had much opportunity to prowl around on github.
    Nice place to find programming tools. Github claims a few million depositories are stored there. I guess that's why you may be able to find just about anything related to programming, particularly for anything close to Unix/Linux, etc.
     
  5. D.T. macrumors 603

    D.T.

    Joined:
    Sep 15, 2011
    Location:
    Vilano Beach, FL
    #5
    We use AFNetworking:

    http://cocoadocs.org/docsets/AFNetworking/1.3.1/index.html

    Check out the AFHTTPClient and AFJSONRequestOperation classes:

    http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFHTTPClient.html

    http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFJSONRequestOperation.html


    Rolled our own datasource/connection library that builds the request with the proper method, path and header (for authentication). It’s very popular, so there’s a ton of examples for consuming RESTful web services.
     
  6. ArtOfWarfare thread starter macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #6
    T.T

    So I read through the whole tutorial they have posted for RestKit. On their TODO list is explaining how to use it to upload anything.

    Honestly, why did anyone go through the effort of writing all this code if they couldn't be bothered to make it useful and document it? It seems to me my options are to try reading and understanding their undocumented code, no small feat, or to just ignore that it exists and roll my own.
     
  7. Tander macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #7
    As D.T stated - I also use AFNetworking 2.0. Much easier and very well documented. You don't need to go through tutorials to understand how it works.
     
  8. ArtOfWarfare thread starter macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #8
    Hm. I swapped to MKNetworkKit last night and have definitely preferred it so far. Is AFNetworking 2.0 better still?
     
  9. Tander macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #9
    I've never used MKNetworkKit so I cannot make a comparison between the two libraries.

    I like AFN due to its ease of use and its well documented APi.
     
  10. Sean7512 macrumors 6502a

    Joined:
    Jun 8, 2005
    #10
    AFN is a great library, but use what is working that has the capability you need.

    You can always swap it out at a later time, shouldn't be that hard.
     

Share This Page