-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
result.operation is nil when calling AFMotion::JSON.get #24
Comments
|
No, actually it create and NSMutableURLRequest def createRequest(url)
request = NSMutableURLRequest.requestWithURL(NSURL.URLWithString(url),
cachePolicy: NSURLRequestReloadIgnoringLocalCacheData,
timeoutInterval: 300)
apiVersion = NSBundle.mainBundle.objectForInfoDictionaryKey('ApiVersion')
request.setValue(apiVersion, forHTTPHeaderField: 'ApiVersion')
request
end I think the problem is how the AFMotion::Operation::JSON.for_request closes over the variable operation. Reimplementing AFMotion::Operation::JSON.for_request to look more like the HTTP.for_request solves the problem for me: def json_get_request(request, &callback)
operation = AFJSONRequestOperation.alloc.initWithRequest(request)
operation.setCompletionBlockWithSuccess(
lambda { |operation, responseObject|
result = AFMotion::HTTPResult.new(operation, responseObject, nil)
callback.call(result)
},
failure: lambda {|operation, error|
result = AFMotion::HTTPResult.new(operation, nil, error)
callback.call(result)
}
)
operation
end |
And to answer your questions: :-) request (returned from createRequest) is a String right? |
Ah I see; yeah the code-paths when passing |
What is the alternative method? :-) |
The alternative method is to passing a String, which will get converted to an |
After upgrading to the latest version of RubyMotion, the following code does not work anymore, because result.operation is 'nil'.
We are using RubyMotion v2.9 and AFMotion 0.9.0. The problem started occurring when we upgrade RubyMotion from v2.3 to v2.9.
The text was updated successfully, but these errors were encountered: