NSURLErrorDomain
iOS 13
Error Code -1103
resource size limit
iOS development

-1103 Error DomainNSURLErrorDomain Code-1103 resource exceeds maximum size iOS 13

Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms

Introduction

NSURLErrorDomain code -1103 usually appears when an iOS app tries to load more response data than the current request path can handle comfortably. In practice, it often means the app is treating a very large resource like a small one and needs a different download strategy.

What the Error Means

This error is commonly surfaced as “resource exceeds maximum size.” The key point is that the request did not fail because the URL was invalid or the server was unreachable. It failed because the transfer or in-memory handling of the response crossed a size threshold that the networking stack considered unsafe for that path.

Typical triggers include:

  • Downloading a very large image, archive, or video with dataTask.
  • Returning an unexpectedly huge JSON payload.
  • Loading the entire response into memory before writing it to disk.
  • Fetching content that should be paginated or streamed.

The error shows up more often on older devices or in memory-constrained conditions because the effective headroom is lower.

Prefer Downloading to Disk for Large Files

If the resource is large, switch from dataTask to downloadTask. A downloadTask writes the response to a temporary file instead of building a huge Data value in memory.

Here is a simple Swift example:

swift
1import Foundation
2
3let url = URL(string: "https://example.com/large-file.zip")!
4let task = URLSession.shared.downloadTask(with: url) { tempURL, response, error in
5    if let error = error {
6        print("Download failed:", error.localizedDescription)
7        return
8    }
9
10    guard let tempURL = tempURL else {
11        print("Missing temporary file")
12        return
13    }
14
15    let destination = FileManager.default.temporaryDirectory
16        .appendingPathComponent("large-file.zip")
17
18    do {
19        try? FileManager.default.removeItem(at: destination)
20        try FileManager.default.moveItem(at: tempURL, to: destination)
21        print("Saved to", destination.path)
22    } catch {
23        print("File move failed:", error.localizedDescription)
24    }
25}
26
27task.resume()
28RunLoop.main.run()

This is safer than:

swift
URLSession.shared.dataTask(with: url) { data, _, _ in
    print(data?.count ?? 0)
}.resume()

That second pattern is fine for modest JSON responses, but it is a poor fit for large assets.

Reduce the Size of What You Request

Sometimes the fix is not on the client side alone. If the server returns far more data than the app needs, reduce the payload:

  • Paginate list endpoints.
  • Request thumbnails instead of full-size images for list views.
  • Enable compression where appropriate.
  • Support range requests for media or resumable downloads.

For example, if you only need a summary page:

swift
1var components = URLComponents(string: "https://api.example.com/items")!
2components.queryItems = [
3    URLQueryItem(name: "page", value: "1"),
4    URLQueryItem(name: "pageSize", value: "50")
5]
6
7let url = components.url!

Large “get everything” responses are a common reason for -1103.

Inspect the Response Before Processing It

You can often detect trouble early by checking response metadata:

swift
1URLSession.shared.dataTask(with: url) { data, response, error in
2    if let http = response as? HTTPURLResponse,
3       let length = http.value(forHTTPHeaderField: "Content-Length") {
4        print("Content-Length:", length)
5    }
6
7    if let error = error {
8        print("Request error:", error.localizedDescription)
9        return
10    }
11
12    print("Bytes in memory:", data?.count ?? 0)
13}.resume()

This will not solve the issue by itself, but it helps confirm whether you are pulling back a response that should have been streamed or chunked.

Handle Large Media Deliberately

If the resource is an image, do not decode a massive original image on the main thread and then display it at thumbnail size. If it is video, avoid downloading the entire file into memory. If it is JSON, do not model a single endpoint around unbounded arrays.

The best fix is usually architectural: use the right transfer mode for the type and size of data you expect.

Common Pitfalls

The most common mistake is assuming all URLSession tasks are interchangeable. They are not. dataTask is for smaller responses you want in memory, while downloadTask is designed for larger transfers.

Another mistake is testing only on fast Wi-Fi with small sample files. Production traffic often includes slower networks and much bigger payloads than local fixtures.

Developers also focus only on the client and ignore the backend. If the server ships multi-megabyte JSON documents or original-resolution images to every screen, client-side fixes will only go so far.

Finally, do not swallow the original NSError. Log the failing URL, headers, and approximate response size. Without that context, -1103 is hard to diagnose.

Summary

  • '-1103 usually means the app is trying to handle a response that is too large for the chosen request path.'
  • Use downloadTask for large files instead of dataTask.
  • Shrink payloads with pagination, compression, or smaller asset variants.
  • Check headers such as Content-Length when diagnosing the issue.
  • Treat the problem as both a networking choice and a payload-design problem.

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms