问题
I need to pass text string up to 20Kb (one NSURLQueryItem value) from one iOS app to another using schemes. I was able to pass not such long URL between the apps.
What is max NSURL length supported? Does it depend on iOS version? Is there any better approach to send text long string?
回答1:
NSURL can easily handle 20Kb.
The implementation limitation is around 2Gb (INT_MAX
) for the URL string. The limitations you'll run into first with large URLs are memory and time. You'll run out of memory for the allocations at some point (For 32-bit executables, the limitation is a little over 1.1GB when your process runs out of address space; for 64-bit executables, the limitation depends on your system's available VM swap space). Creating very large URLs will take a lot of time to create and parse.
回答2:
Did you get a 414 (request too long) on your request? There is no formal limit, but systems have ad hoc limits which may be as low as 8k.
You should use a POST instead of putting all the data in the URL.
来源:https://stackoverflow.com/questions/34730218/nsurl-max-length