Post

Replies

Boosts

Views

Activity

Comment on URLSession.dataTask(with: URL) error: Type of expression is ambiguous without a type annotation
I tried removing the do block outside the task and it made no difference. But then I tried removing these two lines: let decoder = JSONDecoder() let ar = try decoder.decode(AAA_Result.self, from: response.value) And the problem went away! So: (1) Why doesn't Xcode specify the error on the line that causes the error, and (2) What is the problem with these two lines?
May ’25
Comment on URLSession.dataTask(with: URL) error: Type of expression is ambiguous without a type annotation
Update: When I remove the ".resume()", the subject error returns to the .dataTask() invocation. Sorry -- I thought using Safari was safe since these are Apple developer forums, but every time I tried to comment, it would give me an error and tell me to try again later, hence the multiple comments with the same info... Also, there doesn't seem to be a way to delete your comments...otherwise I would have deleted this one!
May ’25
Comment on URLSession.dataTask(with: URL) error: Type of expression is ambiguous without a type annotation
Thanks for the info about editing! Also, thanks for the suggestion -- I changed my code to look like your snippet, but now I'm getting the subject error on the .resume()! (I tried it both with and without the parentheses around "data, response, error" -- made no difference) Update: I tried removing the ".resume()" -- the subject error goes back to the invocation of ".dataTask(with:)"
May ’25
Comment on URLSession.dataTask(with: URL) error: Type of expression is ambiguous without a type annotation
After doing some debugging, I found that the data contained what I needed, not the response. I simply changed this line: let ar = try decoder.decode(AAA_Result.self, from: response.value) to this, and all is working! let ar = try decoder.decode(AAA_Result.self, from: data!) Thanks very much for pointing me in the right direction!
Replies
Boosts
Views
Activity
May ’25
Comment on URLSession.dataTask(with: URL) error: Type of expression is ambiguous without a type annotation
After reading this post, I copied those lines to a separate function and discovered that response.value is where the problem is. Not sure what the answer is, but the bottom line: I guess you can't trust XCode to tell you where your problem is, at least not in closures!
Replies
Boosts
Views
Activity
May ’25
Comment on URLSession.dataTask(with: URL) error: Type of expression is ambiguous without a type annotation
I tried removing the do block outside the task and it made no difference. But then I tried removing these two lines: let decoder = JSONDecoder() let ar = try decoder.decode(AAA_Result.self, from: response.value) And the problem went away! So: (1) Why doesn't Xcode specify the error on the line that causes the error, and (2) What is the problem with these two lines?
Replies
Boosts
Views
Activity
May ’25
Comment on URLSession.dataTask(with: URL) error: Type of expression is ambiguous without a type annotation
Update: When I remove the ".resume()", the subject error returns to the .dataTask() invocation. Sorry -- I thought using Safari was safe since these are Apple developer forums, but every time I tried to comment, it would give me an error and tell me to try again later, hence the multiple comments with the same info... Also, there doesn't seem to be a way to delete your comments...otherwise I would have deleted this one!
Replies
Boosts
Views
Activity
May ’25
Comment on URLSession.dataTask(with: URL) error: Type of expression is ambiguous without a type annotation
Thanks for the info about editing! Also, thanks for the suggestion -- I changed my code to look like your snippet, but now I'm getting the subject error on the .resume()! (I tried it both with and without the parentheses around "data, response, error" -- made no difference) Update: I tried removing the ".resume()" -- the subject error goes back to the invocation of ".dataTask(with:)"
Replies
Boosts
Views
Activity
May ’25