rsieiro / RSOAuthEngine

ARC based OAuth engine for MKNetworkKit
http://rodrigo.sharpcube.com
150 stars 33 forks source link

mk_urlEncodedString #15

Closed triage closed 11 years ago

triage commented 11 years ago

hey there appears that mk_urlEncodedString isn't in MKNetworkKit anymore

rsieiro commented 11 years ago

Just checked, it's still there. Ref: https://github.com/MugunthKumar/MKNetworkKit/blob/master/MKNetworkKit/Categories/NSString+MKNetworkKitAdditions.h

Are you sure you're using the correct version of MKNetworkKit?

triage commented 11 years ago

apologies. had to have :head in the podfile

rsieiro commented 11 years ago

No prob :)

On 13/02/2013, at 02:33, triage notifications@github.com wrote:

apologies. had to have :head in the podfile

— Reply to this email directly or view it on GitHubhttps://github.com/rsieiro/RSOAuthEngine/issues/15#issuecomment-13474199.

triage commented 11 years ago

ok ... now that everything compiles, here's the other issue: I'm sending params on a signed operation with a POST MK only ships with NSString+MKNetworkKitAdditions.h/.m, which has the category method mk_urlEncodedString however values in params are likely to be things other than just strings like nsnumber, nsarray, nsdictionary, etc.

in RSOAuthEngine.m, you have: [parameters addObject:[NSDictionary dictionaryWithObjectsAndKeys:[key mk_urlEncodedString], @"key", [obj mk_urlEncodedString], @"value", nil]];

problem is obviously, that value may likely not be an NSString, and so I was getting selector not found [NSCFNumber mk_urlEncodedString]

so what do you think about something like this, starting on lines 218, nearly identical to what MK is doing in NSDictionary+RequestEncoding.m in -(NSString*) urlEncodedKeyValueString

        [request.readonlyPostDictionary enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
            NSObject *value = obj;
            if([value isKindOfClass:[NSString class]])
            {
                [parameters addObject:[NSDictionary dictionaryWithObjectsAndKeys:[key mk_urlEncodedString], @"key", [obj mk_urlEncodedString], @"value", nil]];
            }
            else
            {
                [parameters addObject:@{
                    @"key":[key mk_urlEncodedString],
                    @"value":[NSString stringWithFormat:@"%@",value]
                 }];
            }
        }];
rsieiro commented 11 years ago

Yeah, that could be a nice convenience.

I'm currently very busy with a project, so I can't stop to work on this at the moment. But feel free to send a pull request!

triage commented 11 years ago

will do!