Pregunta

I tried to load a list of the user's Twitter followers. It loads fine on iOS 7.1, but crashes on iOS 6.1. The line that crashes is performRequestWithHandler: and the error is -[__NSCFNumber length]: unrecognized selector sent to instance 0xcb4d580. What is the cause of the problem?

SLRequest* request = [SLRequest
    requestForServiceType:SLServiceTypeTwitter
    requestMethod:TWRequestMethodGET
    URL:[NSURL URLWithString:[NSString stringWithFormat:
        @"%@followers/list.json",
        API_BASE_URL
    ]]
    parameters:@{
        @"user_id": @(self.context.userId.integerValue),
        @"count": @(128),
        @"skip_status": @"true"
    }
];
request.account = self.context.account;
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
    // code that is irrelevant to crash
}];

These are how the above variables are defined:

  • API_BASE_URL is a static NSString @"https://api.twitter.com/1.1/"
  • self.context.userId is an NSString of a number.
  • self.context.account is the ACAccount of the logged in user.
¿Fue útil?

Solución

Given the error message it seems under iOS 6 you must be sure all request parameters are strings. Change your code for the parameters to something like:

parameters:@{
    @"user_id": self.context.userId,
    @"count": @"128",
    @"skip_status": @"true"
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top