crino / instagram-ios-sdk

Instagram SDK for iOS
http://www.followgram.me
228 stars 63 forks source link

Is there a way where I can differentiate between different requests? #37

Closed RyanTLX closed 10 years ago

RyanTLX commented 10 years ago

When a view is loaded, I send out 2 requests, 1st is requesting for users/self/feed" (user feed), and 2nd is requesting for "users/self" (user info).

Those 2 requests may not be returned in the order that I have requested them. Is there a way that I can differentiate between the 2 requests since Instagram always returns the JSON dictionary as "data"?

Otherwise the next solution I can think of, which I don't prefer, is to wait till I receive the results of the 1st request before I start sending the 2nd request.

crino commented 10 years ago

You could set tag on each request or keep the reference of request and check it on delegate.

RyanTLX commented 10 years ago

Is it possible for you to elaborate what do you mean by setting a tag on a request, or keeping a reference of a request and checking it on delegate?

crino commented 10 years ago
....
IGRequest *request = [appDelegate.instagram requestWithParams:params                     delegate:self];
request.tag = FOLLOWERS_REQ_TAG;
....
- (void)request:(IGRequest *)request didLoad:(id)result {
    if (request.tag == FOLLOWERS_REQ_TAG) {
        // is my request
    }
}
RyanTLX commented 10 years ago

Great! I had to to go IGRequest.h to add a tag property first before that could work. Thanks!

@property(nonatomic) int tag;
crino commented 10 years ago

Yes, sorry was my wrong. If you don't want change the library keep the reference of the request from 'requestWithParams....'